From 8894d7e33fbe2e1da9b1aad101801e849df24c08 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 | 54 ++++++++++++++++++++++++ .pylintrc | 34 +++++++++++++++ .python-version | 1 + .ruff.toml | 76 ++++++++++++++++++++++++++++++++++ python/.gitignore | 3 +- 5 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/code-qa.yaml create mode 100644 .pylintrc create mode 100644 .python-version create mode 100644 .ruff.toml diff --git a/.github/workflows/code-qa.yaml b/.github/workflows/code-qa.yaml new file mode 100644 index 0000000..9d42ec3 --- /dev/null +++ b/.github/workflows/code-qa.yaml @@ -0,0 +1,54 @@ +name: Code-QA + +on: push + +jobs: + mypy: + 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 mypy + run: | + pip install mypy remotivelabs-broker>=0.1.8 pytest + - name: Run mypy + run: | + mypy python --no-namespace-packages + + ruff-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + with: + src: "python" + + ruff-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + with: + src: "python" + args: format --check --diff + + pylint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.8 + architecture: x64 + - name: Install pylint + run: | + pip install pylint + - name: Run pylint + run: pylint python diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..bd4f252 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,34 @@ +[MAIN] +py-version=3.8 +ignore=.venv + +good-names-rgxs=__,.*__.* + +[DESIGN] +max-args=7 +max-attributes=11 + + +[FORMAT] +max-line-length=140 +max-module-lines=1000 + + +[MESSAGES CONTROL] +disable=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + use-implicit-booleaness-not-comparison-to-string, + use-implicit-booleaness-not-comparison-to-zero, + missing-function-docstring, + missing-class-docstring, + missing-module-docstring, + logging-fstring-interpolation, + broad-exception-raised, + too-few-public-methods, + cell-var-from-loop 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/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..5723aa8 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,76 @@ +# Exclude a variety of commonly ignored directories. +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__' +] + +line-length = 140 +indent-width = 4 + +# Assume Python 3.8 +target-version = "py38" + +[lint] +select = ["C901", "E", "W", "F", "RET505", "I001", "B034", "EXE001", "N", "UP032", "FA"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" 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__