From b6a25e76127cb4dcbdbb6ec808f1f3dce7e8efa1 Mon Sep 17 00:00:00 2001 From: Antoine Lambert <anlambert@softwareheritage.org> Date: Fri, 14 Feb 2025 14:36:46 +0100 Subject: [PATCH] Apply swh-py-template v0.3.3 with copier Bump development tools: mypy, codespell, isort, ... Move all tools configuration in pyproject.toml. Remove no longer needed mypy overrides. --- .copier-answers.yml | 2 +- .pre-commit-config.yaml | 12 ++++++------ mypy.ini | 26 -------------------------- pyproject.toml | 35 +++++++++++++++++++++++++++++++++++ pytest.ini | 7 ------- requirements-test.txt | 1 + setup.cfg | 9 --------- tox.ini | 8 +++++--- 8 files changed, 48 insertions(+), 52 deletions(-) delete mode 100644 mypy.ini delete mode 100644 pytest.ini delete mode 100644 setup.cfg diff --git a/.copier-answers.yml b/.copier-answers.yml index 9a2a43d..8d87d2a 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v0.2.3 +_commit: v0.3.3 _src_path: https://gitlab.softwareheritage.org/swh/devel/swh-py-template.git description: Software Heritage CVS Loader distribution_name: swh-loader-cvs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ce0872a..5ddf293 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace exclude: cvs2gitdump|rcsparse @@ -8,13 +8,13 @@ repos: - id: check-yaml - repo: https://github.com/python/black - rev: 24.8.0 + rev: 25.1.0 hooks: - id: black exclude: cvs2gitdump|rcsparse - repo: https://github.com/PyCQA/isort - rev: 5.13.2 + rev: 6.0.0 hooks: - id: isort exclude: cvs2gitdump|rcsparse @@ -23,16 +23,16 @@ repos: rev: 7.1.1 hooks: - id: flake8 - additional_dependencies: [flake8-bugbear==24.4.26] + additional_dependencies: [flake8-bugbear==24.12.12, flake8-pyproject] exclude: cvs2gitdump|rcsparse - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell name: Check source code spelling exclude: cvs2gitdump|rcsparse - stages: [commit] + stages: [pre-commit] - id: codespell name: Check commit message spelling stages: [commit-msg] diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 0845beb..0000000 --- a/mypy.ini +++ /dev/null @@ -1,26 +0,0 @@ -[mypy] -namespace_packages = True -warn_unused_ignores = True -explicit_package_bases = True -# ^ Needed for mypy to detect py.typed from swh packages installed -# in editable mode -exclude = ^swh/loader/cvs/(rcsparse|cvs2gitdump)/ - -# 3rd party libraries without stubs (yet) - -[mypy-pkg_resources.*] -ignore_missing_imports = True - -[mypy-celery.*] -ignore_missing_imports = True - -[mypy-iso8601.*] -ignore_missing_imports = True - -[mypy-pytest.*] -ignore_missing_imports = True - -[mypy-swh.loader.*] -ignore_missing_imports = True -# Ignore rcsparse and cvs2gitdump which will be discovered when imported -follow_imports = silent diff --git a/pyproject.toml b/pyproject.toml index 1710b50..a3ace11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,3 +55,38 @@ ensure_newline_before_comments = true line_length = 88 force_sort_within_sections = true known_first_party = ['swh'] + +[tool.mypy] +namespace_packages = true +warn_unused_ignores = true +explicit_package_bases = true +exclude = "^swh/loader/cvs/(rcsparse|cvs2gitdump)/" + +# ^ Needed for mypy to detect py.typed from swh packages installed +# in editable mode + +plugins = [] + +# 3rd party libraries without stubs (yet) +[[tool.mypy.overrides]] +module = [ + "swh.loader.*", +] +# Ignore rcsparse and cvs2gitdump which will be discovered when imported +follow_imports = "silent" + + +[tool.flake8] +select = ["C", "E", "F", "W", "B950"] +ignore = [ + "E203", # whitespaces before ':' <https://github.com/psf/black/issues/315> + "E231", # missing whitespace after ',' + "E501", # line too long, use B950 warning from flake8-bugbear instead + "W503" # line break before binary operator <https://github.com/psf/black/issues/52> +] +max-line-length = 88 + +[tool.pytest.ini_options] +norecursedirs = "build docs .*" +asyncio_mode = "strict" +consider_namespace_packages = true diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 5fecb0c..0000000 --- a/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[pytest] -norecursedirs = build docs .* -asyncio_mode = strict -consider_namespace_packages = true - -markers = - fs: execute tests that write to the filesystem diff --git a/requirements-test.txt b/requirements-test.txt index cb70fff..757c9e6 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,3 +1,4 @@ +celery-types pytest >= 8.1 pytest-mock swh.loader.core[testing] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7cd7515..0000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[flake8] -# E203: whitespaces before ':' <https://github.com/psf/black/issues/315> -# E231: missing whitespace after ',' -# E501: line too long, use B950 warning from flake8-bugbear instead -# W503: line break before binary operator <https://github.com/psf/black/issues/52> -select = C,E,F,W,B950 -ignore = E203,E231,E501,E704,W503 -max-line-length = 88 -exclude = .*, build, swh/loader/cvs/rcsparse, swh/loader/cvs/cvs2gitdump diff --git a/tox.ini b/tox.ini index c0a4e0e..1dc179e 100644 --- a/tox.ini +++ b/tox.ini @@ -26,7 +26,7 @@ commands = [testenv:black] skip_install = true deps = - black==24.8.0 + black==25.1.0 commands = {envpython} -m black --check swh @@ -34,8 +34,10 @@ commands = skip_install = true deps = flake8==7.1.1 - flake8-bugbear==24.4.26 + flake8-bugbear==24.12.12 + flake8-pyproject==1.2.3 pycodestyle==2.12.1 + commands = {envpython} -m flake8 @@ -43,7 +45,7 @@ commands = extras = testing deps = - mypy==1.11.1 + mypy==1.15.0 commands = mypy swh -- GitLab