From b8e9fc500dde476f622d488bfdb3315bb0e1bc84 Mon Sep 17 00:00:00 2001 From: "Scheidt, Fabian" Date: Tue, 2 Jul 2024 16:10:50 +0200 Subject: [PATCH] feat: bump code quality tooling Updates pre-commit, black, pylint, isort and prettier to current versions --- .pre-commit-config.yaml | 8 ++-- .pylintrc | 38 +++++++++++++++---- environment.yaml | 6 +-- .../.pre-commit-config.yaml | 15 +++----- {{cookiecutter.repo_name}}/.pylintrc | 38 +++++++++++++++---- {{cookiecutter.repo_name}}/environment.yaml | 8 ++-- 6 files changed, 76 insertions(+), 37 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e9274b..d3625bc 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_install_hook_types: [pre-commit, commit-msg] default_stages: [commit, manual] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-added-large-files args: @@ -23,10 +23,10 @@ repos: - manual - id: requirements-txt-fixer - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v9.11.0 + rev: v9.16.0 hooks: - id: commitlint - additional_dependencies: ['@commitlint/config-conventional@18.6.2'] + additional_dependencies: ['@commitlint/config-conventional@19.2.2'] pass_filenames: true stages: - commit-msg @@ -52,7 +52,7 @@ repos: language: system types: [python] - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 + rev: v3.1.0 hooks: - id: prettier stages: diff --git a/.pylintrc b/.pylintrc index 09c6dbf..b5b9ff6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -59,10 +59,11 @@ ignore-paths= # Emacs file locks ignore-patterns=^\.# -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It -# supports qualified module names, as well as Unix pattern matching. +# List of module names for which member attributes should not be checked and +# will not be imported (useful for modules/projects where namespaces are +# manipulated during runtime and thus existing member attributes cannot be +# deduced by static analysis). It supports qualified module names, as well as +# Unix pattern matching. ignored-modules= # Python code to execute, usually for sys.path manipulation such as @@ -86,6 +87,10 @@ load-plugins= # Pickle collected data for later comparisons. persistent=yes +# Resolve imports to .pyi stubs if available. May reduce no-member messages and +# increase not-an-iterable messages. +prefer-stubs=no + # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. py-version=3.10 @@ -93,6 +98,12 @@ py-version=3.10 # Discover python modules and packages in the file system subtree. recursive=no +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots= + # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages. suggestion-mode=yes @@ -229,6 +240,10 @@ no-docstring-rgx=^_ # These decorators are taken in consideration only for invalid-name. property-classes=abc.abstractproperty +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +#typealias-rgx= + # Regular expression matching correct type variable names. If left empty, type # variable names will be checked with the set naming style. #typevar-rgx= @@ -251,6 +266,7 @@ check-protected-access-in-special-methods=no defining-attr-methods=__init__, __new__, setUp, + asyncSetUp, __post_init__ # List of member names, which should be excluded from the protected access @@ -483,6 +499,11 @@ max-nested-blocks=5 # printed. never-returning-functions=sys.exit,argparse.parse_error +# Let 'consider-using-join' be raised when the separator to join on would be +# non-empty (resulting in expected fixes of the type: ``"- " + " - +# ".join(items)``) +suggest-join-with-non-empty-separator=yes + [REPORTS] @@ -497,8 +518,9 @@ evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor # used to format the message information. See doc for all details. msg-template= -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. +# Set the output format. Available formats are: text, parseable, colorized, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. # mypackage.mymodule.MyReporterClass. #output-format= @@ -532,8 +554,8 @@ min-similarity-lines=4 # Limits count of emitted suggestions for spelling mistakes. max-spelling-suggestions=4 -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the 'python-enchant' package. +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work. spelling-dict= # List of comma separated words that should be considered directives if they diff --git a/environment.yaml b/environment.yaml index e7ae5c3..b888781 100644 --- a/environment.yaml +++ b/environment.yaml @@ -2,10 +2,10 @@ name: data-science-project-template channels: - conda-forge dependencies: - - black=23.1.0 + - black=24.4.2 - python=3.10.9 - - pre-commit=3.0.4 - - pylint=2.16.1 + - pre-commit=3.7.1 + - pylint=3.2.5 - pytest=7.2.1 - cookiecutter=2.1.1 - pytest=7.2.1 diff --git a/{{cookiecutter.repo_name}}/.pre-commit-config.yaml b/{{cookiecutter.repo_name}}/.pre-commit-config.yaml index f3721b1..6d42f1c 100644 --- a/{{cookiecutter.repo_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.repo_name}}/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_install_hook_types: [pre-commit, commit-msg] default_stages: [commit, manual] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-added-large-files args: @@ -25,15 +25,15 @@ repos: - manual - id: requirements-txt-fixer - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v9.11.0 + rev: v9.16.0 hooks: - id: commitlint - additional_dependencies: ['@commitlint/config-conventional'] + additional_dependencies: ['@commitlint/config-conventional@19.2.2'] pass_filenames: true stages: - commit-msg - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) @@ -48,11 +48,6 @@ repos: args: [--config=./pyproject.toml] language: system types: [python] - - id: nbqa-black - name: nbqa-black - entry: nbqa black - language: system - files: \.ipynb - id: pylint name: pylint entry: pylint @@ -67,7 +62,7 @@ repos: - --disable=pointless-statement,duplicate-code,expression-not-assigned - --const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__)|([a-z_][a-z0-9_]{0,50}))$ - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 + rev: v3.1.0 hooks: - id: prettier stages: diff --git a/{{cookiecutter.repo_name}}/.pylintrc b/{{cookiecutter.repo_name}}/.pylintrc index 09c6dbf..b5b9ff6 100644 --- a/{{cookiecutter.repo_name}}/.pylintrc +++ b/{{cookiecutter.repo_name}}/.pylintrc @@ -59,10 +59,11 @@ ignore-paths= # Emacs file locks ignore-patterns=^\.# -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It -# supports qualified module names, as well as Unix pattern matching. +# List of module names for which member attributes should not be checked and +# will not be imported (useful for modules/projects where namespaces are +# manipulated during runtime and thus existing member attributes cannot be +# deduced by static analysis). It supports qualified module names, as well as +# Unix pattern matching. ignored-modules= # Python code to execute, usually for sys.path manipulation such as @@ -86,6 +87,10 @@ load-plugins= # Pickle collected data for later comparisons. persistent=yes +# Resolve imports to .pyi stubs if available. May reduce no-member messages and +# increase not-an-iterable messages. +prefer-stubs=no + # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. py-version=3.10 @@ -93,6 +98,12 @@ py-version=3.10 # Discover python modules and packages in the file system subtree. recursive=no +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots= + # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages. suggestion-mode=yes @@ -229,6 +240,10 @@ no-docstring-rgx=^_ # These decorators are taken in consideration only for invalid-name. property-classes=abc.abstractproperty +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +#typealias-rgx= + # Regular expression matching correct type variable names. If left empty, type # variable names will be checked with the set naming style. #typevar-rgx= @@ -251,6 +266,7 @@ check-protected-access-in-special-methods=no defining-attr-methods=__init__, __new__, setUp, + asyncSetUp, __post_init__ # List of member names, which should be excluded from the protected access @@ -483,6 +499,11 @@ max-nested-blocks=5 # printed. never-returning-functions=sys.exit,argparse.parse_error +# Let 'consider-using-join' be raised when the separator to join on would be +# non-empty (resulting in expected fixes of the type: ``"- " + " - +# ".join(items)``) +suggest-join-with-non-empty-separator=yes + [REPORTS] @@ -497,8 +518,9 @@ evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor # used to format the message information. See doc for all details. msg-template= -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. +# Set the output format. Available formats are: text, parseable, colorized, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. # mypackage.mymodule.MyReporterClass. #output-format= @@ -532,8 +554,8 @@ min-similarity-lines=4 # Limits count of emitted suggestions for spelling mistakes. max-spelling-suggestions=4 -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the 'python-enchant' package. +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work. spelling-dict= # List of comma separated words that should be considered directives if they diff --git a/{{cookiecutter.repo_name}}/environment.yaml b/{{cookiecutter.repo_name}}/environment.yaml index c4999b7..9c1b46c 100644 --- a/{{cookiecutter.repo_name}}/environment.yaml +++ b/{{cookiecutter.repo_name}}/environment.yaml @@ -2,11 +2,11 @@ name: '{{cookiecutter.env_name}}' channels: - conda-forge dependencies: - - black=23.1.0 - - nbqa=1.6.1 + - black=24.4.2 + - nbqa=1.8.5 {%- if cookiecutter.install_jupyter == 'yes' %} - jupyter=1.0.0 {%- endif %} - python=3.10.9 - - pre-commit=3.0.4 - - pylint=2.16.1 + - pre-commit=3.7.1 + - pylint=3.2.5