diff --git a/.copier-answers.yml b/.copier-answers.yml index 142939a715033af0502aa3c709179d76cb2de006..7b97e9ff06a1522d462754e45477d7e4472a7a98 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 data model distribution_name: swh-model diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a8b70933a2f286f618262d2800e60368dbc10400..5df993fa078dd13a505496954e4e2848fa75081a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,18 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: check-json - id: check-yaml - repo: https://github.com/python/black - rev: 24.8.0 + rev: 25.1.0 hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: 5.13.2 + rev: 6.0.0 hooks: - id: isort @@ -20,15 +20,15 @@ repos: rev: 7.1.1 hooks: - id: flake8 - additional_dependencies: [flake8-bugbear==24.4.26] + additional_dependencies: [flake8-bugbear==24.12.12, flake8-pyproject] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell name: Check source code spelling - stages: [commit] - args: [-L assertIn] + stages: [pre-commit] + args: [-L assertIn, -L anc] - id: codespell name: Check commit message spelling stages: [commit-msg] diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 2f09ec1206332b62139f5d945e5fabbe1c165d2b..0000000000000000000000000000000000000000 --- a/mypy.ini +++ /dev/null @@ -1,13 +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 - -# 3rd party libraries without stubs (yet) -[mypy-pkg_resources.*] -ignore_missing_imports = True - -# [mypy-add_your_lib_here.*] -# ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 5f4640e4c98de431c9f0619f5a19772620a26ae8..751ebbec57d44746e43de18daf9dbb8f40fa9cb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,3 +59,40 @@ 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 +# ^ 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 = [ +# "package1.*", +# "package2.*", +# ] +# ignore_missing_imports = true + +[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] +addopts = "--doctest-modules -p no:pytest_swh_core" +norecursedirs = "build docs .*" +asyncio_mode = "strict" +consider_namespace_packages = true +markers = [ + "fs: tests that involve filesystem ios", + "requires_optional_deps: tests in test_cli.py that should not run if optional dependencies are not installed", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 2677d2a7bf6b29d029d50f955baa8ae559aaebd3..0000000000000000000000000000000000000000 --- a/pytest.ini +++ /dev/null @@ -1,12 +0,0 @@ -[pytest] -norecursedirs = build docs .* -asyncio_mode = strict -consider_namespace_packages = true - -addopts = - --doctest-modules - -p no:pytest_swh_core - -markers = - fs: tests that involve filesystem ios - requires_optional_deps: tests in test_cli.py that should not run if optional dependencies are not installed diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index adf9af3e48c7da13135e5dfb6505a1909bc26066..0000000000000000000000000000000000000000 --- a/setup.cfg +++ /dev/null @@ -1,8 +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 diff --git a/swh/model/git_objects.py b/swh/model/git_objects.py index a1e429396803b393841e0397922532934ba4b0ff..679011b5d6e616841764474e1b91295e4a49d56f 100644 --- a/swh/model/git_objects.py +++ b/swh/model/git_objects.py @@ -516,7 +516,7 @@ def snapshot_git_object( def raw_extrinsic_metadata_git_object( - metadata: Union[Dict, model.RawExtrinsicMetadata] + metadata: Union[Dict, model.RawExtrinsicMetadata], ) -> bytes: """Formats RawExtrinsicMetadata as a git-like object. diff --git a/swh/model/model.py b/swh/model/model.py index e6b99a6cee2a4defc42cc44a97f0d5c9e9359f9d..7745e539ae6a9156791cc909c8f66deda7cde2a6 100644 --- a/swh/model/model.py +++ b/swh/model/model.py @@ -85,7 +85,7 @@ def parents_repr(parents: Tuple[Sha1Git, ...]): def freeze_optional_dict( - d: Union[None, Dict, ImmutableDict] + d: Union[None, Dict, ImmutableDict], ) -> Optional[ImmutableDict]: if isinstance(d, dict): return ImmutableDict(d) diff --git a/swh/model/swhids.py b/swh/model/swhids.py index 6464c8b08ef67501e090c2bef9efcdd65c9958cd..3422d6fa421a10532866110033ab2b715f2c0ed0 100644 --- a/swh/model/swhids.py +++ b/swh/model/swhids.py @@ -217,7 +217,7 @@ def _parse_core_swhid(swhid: Union[str, CoreSWHID, None]) -> Optional[CoreSWHID] def _parse_lines_qualifier( - lines: Union[str, Tuple[int, Optional[int]], None] + lines: Union[str, Tuple[int, Optional[int]], None], ) -> Optional[Tuple[int, Optional[int]]]: try: if lines is None or isinstance(lines, tuple): diff --git a/tox.ini b/tox.ini index 64250fd9245cc6d47f283a74b7187cd3f8e4b378..f1980be2d6ab2cd3e82f5fa8e53d18c4f5cea640 100644 --- a/tox.ini +++ b/tox.ini @@ -30,7 +30,7 @@ commands = [testenv:black] skip_install = true deps = - black==24.8.0 + black==25.1.0 commands = {envpython} -m black --check swh @@ -38,8 +38,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 @@ -47,7 +49,7 @@ commands = extras = testing deps = - mypy==1.11.1 + mypy==1.15.0 commands = mypy swh