From a33cf0526eeb10eb7714b9988f2bb5720560f168 Mon Sep 17 00:00:00 2001 From: Johan Karlberg Date: Wed, 17 Apr 2024 15:55:15 +0200 Subject: [PATCH] test linting --- .github/workflows/code-qa.yaml | 23 ++++++++ .gitignore | 3 +- .python-version | 1 + pyproject.toml | 100 +++++++++++++++++++++++++++++++++ python/.gitignore | 3 +- python/Makefile | 38 +++++++++++++ 6 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/code-qa.yaml create mode 100644 .python-version create mode 100644 pyproject.toml create mode 100644 python/Makefile diff --git a/.github/workflows/code-qa.yaml b/.github/workflows/code-qa.yaml new file mode 100644 index 0000000..efe9cdd --- /dev/null +++ b/.github/workflows/code-qa.yaml @@ -0,0 +1,23 @@ +name: Code-QA + +on: push + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.8.18 + architecture: x64 + - name: Checkout + uses: actions/checkout@v4 + - name: Install deps + run: | + pip install mypy==1.8.0 pylint==3.2.5 ruff==0.1.14 remotivelabs-broker>=0.1.8 pytest + - name: Run lint + run: | + cd python + make + cd - diff --git a/.gitignore b/.gitignore index 29b636a..914ee53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -*.iml \ No newline at end of file +*.iml +.venv diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..cc1923a --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.8 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3973adf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,100 @@ +[tool.ruff] +line-length = 140 +indent-width = 4 +exclude = [ + '.bzr', + '.direnv', + '.eggs', + '.git', + '.git-rewrite', + '.hg', + '.ipynb_checkpoints', + '.mypy_cache', + '.nox', + '.pants.d', + '.pyenv', + '.pytest_cache', + '.pytype', + '.ruff_cache', + '.svn', + '.tox', + '.venv', + '.vscode', + '__pypackages__', + '_build', + 'buck-out', + 'build', + 'dist', + 'node_modules', + 'site-packages', + 'venv', + 'deps', + 'binaries', + '__pycache__' +] +[tool.ruff.lint] +select = ['C901', 'E', 'W', 'F', 'RET505', 'I001', 'B034', 'EXE001', 'N', 'UP032', 'FA'] +ignore = [] +mccabe = { max-complexity = 14 } + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false + +[tool.pylint] +ignore=[ + '.bzr', + '.direnv', + '.eggs', + '.git', + '.git-rewrite', + '.hg', + '.ipynb_checkpoints', + '.mypy_cache', + '.nox', + '.pants.d', + '.pyenv', + '.pytest_cache', + '.pytype', + '.ruff_cache', + '.svn', + '.tox', + '.venv', + '.vscode', + '__pypackages__', + '_build', + 'buck-out', + 'build', + 'dist', + 'node_modules', + 'site-packages', + 'venv', + 'deps', + 'binaries', + '__pycache__' +] +recursive=true + +[tool.pylint.format] +max-line-length=140 +max-module-lines=1000 + +[tool.pylint.messages_control] +disable=['wrong-import-order', + 'missing-module-docstring', + 'missing-class-docstring', + 'missing-function-docstring', + 'duplicate-code'] + +[tool.mypy] +strict = true +allow_untyped_calls = true +check_untyped_defs = true +warn_return_any = true +warn_unused_ignores = true +show_error_codes = true + +[[tool.mypy.overrides]] +module = "someip.*" +ignore_missing_imports = true diff --git a/python/.gitignore b/python/.gitignore index 320308f..0cbb74e 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -1,2 +1,3 @@ .pyc -__pycache__ \ No newline at end of file +.venv +__pycache__ diff --git a/python/Makefile b/python/Makefile new file mode 100644 index 0000000..09aa52b --- /dev/null +++ b/python/Makefile @@ -0,0 +1,38 @@ +MAKEFLAGS += -j4 -O +.DEFAULT_GOAL := lint + +.PHONY: lint +lint: pylint mypy ruff-format ruff + +.PHONY: pylint +pylint: + pylint . + @echo "" + +.PHONY: mypy +mypy: + mypy . --config-file ../pyproject.toml --no-namespace-packages + @echo "" + +.PHONY: ruff-format +ruff-format: + ruff format --check --diff + @echo "" + +.PHONY: ruff +ruff: + ruff check + @echo "" + +.PHONY: lint-fix +fix: ruff-fix ruff-format-fix + +.PHONY: ruff-fix +ruff-fix: + ruff check --fix + @echo "" + +.PHONY: ruff-format-fix +ruff-format-fix: + ruff format + @echo ""