From e4d16ec1e813994b5ef606a3091a4be1e5aa2831 Mon Sep 17 00:00:00 2001 From: FestplattenSchnitzel Date: Tue, 20 Sep 2022 12:29:59 +0200 Subject: [PATCH] Move lint tools configuration to pyproject.toml This commit removes the mypy CI job, since there are no or few type hints in the codebase and it failed on unrelated changes in the past. It might be reintroduced when type hints get added. --- .gitlab-ci.yml | 19 ++-------------- .pylint-rcfile | 47 -------------------------------------- mypy.ini | 17 -------------- pyproject.toml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 81 deletions(-) delete mode 100644 .pylint-rcfile delete mode 100644 mypy.ini diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e94e6e1a..baa7ed82 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -219,7 +219,7 @@ lint_format_safety_bandit_checks: --ini .bandit || set_error - safety check --full-report || set_error - - pylint --rcfile=.pylint-rcfile --output-format=colorized --reports=n + - pylint --output-format=colorized --reports=n fdroid makebuildserver setup.py @@ -234,26 +234,11 @@ lint_format_safety_bandit_checks: - exit $EXITVALUE -lint_mypy: - image: debian:bullseye-backports - <<: *apt-template - script: - # use Debian packages to avoid building C/rust sources - - apt-get install - mypy - python3-cryptography - python3-pip - python3-wheel - - apt-get install -t bullseye-backports python3-pyjks - - pip install -e .[test] - - mypy - - black: image: python:slim script: - pip install black - - black --check --diff --color --skip-string-normalization + - black --check --diff --color examples/fdroid_extract_repo_pubkey.py examples/makebuildserver.config.py fdroid diff --git a/.pylint-rcfile b/.pylint-rcfile deleted file mode 100644 index d32d90c4..00000000 --- a/.pylint-rcfile +++ /dev/null @@ -1,47 +0,0 @@ -[MASTER] - -# Use multiple processes to speed up Pylint. -jobs=4 - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence=HIGH,INFERENCE - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=invalid-name,missing-docstring,no-member - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[BASIC] - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,f,fp - - -[ELIF] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -[FORMAT] -max-line-length=88 diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 30ab6eaa..00000000 --- a/mypy.ini +++ /dev/null @@ -1,17 +0,0 @@ -[mypy] -files = fdroidserver -# exclude vendored file -exclude = fdroidserver/apksigcopier.py - -# this is de-facto the linter setting for this file -warn_unused_configs = True - -# TODO: we should either upgrade the used packages to a version which includes type hints OR install/write stub packages for these libraries. -# Further details here: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-type-hints-for-third-party-library -ignore_missing_imports = True - -# ignore the [no-redef] errors, as they collide with the bandit "# nosec" exclusion (common.py) -# unfortunately both tools expect their ignore flag as a comment in the same line -# [misc] is ignored for the "incompatible import" -# [arg-type] is ignored because when there are missing envs, everything will crash, not just the types -disable_error_code = no-redef, misc, arg-type diff --git a/pyproject.toml b/pyproject.toml index 0097e9f6..ba6a2e12 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,64 @@ [tool.black] skip-string-normalization = true +target-version = ["py35"] + + +[tool.mypy] +python_version = "3.5" + +files = "fdroidserver" + +# exclude vendored file +exclude = "fdroidserver/apksigcopier.py" + +# this is de-facto the linter setting for this file +warn_unused_configs = true + +# TODO: we should either upgrade the used packages to a version which includes type hints OR install/write stub packages for these libraries. +# Further details here: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-type-hints-for-third-party-library +ignore_missing_imports = true + +# ignore the [no-redef] errors, as they collide with the bandit "# nosec" exclusion (common.py) +# unfortunately both tools expect their ignore flag as a comment in the same line +# [misc] is ignored for the "incompatible import" +# [arg-type] is ignored because when there are missing envs, everything will crash, not just the types +disable_error_code = "no-redef, misc, arg-type" + + +[tool.pylint.main] +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. +jobs = 4 + +[tool.pylint.basic] +# Good variable names which should always be accepted, separated by a comma. +good-names = ["i", "j", "k", "ex", "Run", "f", "fp"] + +[tool.pylint."messages control"] +# Only show warnings with the listed confidence levels. Leave empty to show all. +# Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, UNDEFINED. +confidence = ["HIGH", "INFERENCE"] + +# Disable the message, report, category or checker with the given id(s). You can +# either give multiple identifiers separated by comma (,) or put this option +# multiple times (only on the command line, not in the configuration file where +# it should appear only once). You can also use "--disable=all" to disable +# everything first and then re-enable specific checks. For example, if you want +# to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable = ["invalid-name", "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", "no-member"] + +[tool.pylint.miscellaneous] +# List of note tags to take in consideration, separated by a comma. +notes = ["FIXME", "XXX", "TODO"] + +[tool.pylint.refactoring] +# Maximum number of nested blocks for function / method body +max-nested-blocks = 5 + +[tool.pylint.format] +# Maximum number of characters on a single line. +max-line-length = 88