diff --git a/.copier-answers.yml b/.copier-answers.yml index c8c7d0fbb4310a7336a1d80bed64b473ccfc36e0..2d83678d32e11366820aa281d4408857e34a0635 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 indexer distribution_name: swh-indexer diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4e2ed8379599b01439a61c7bc864ae760a50e51a..83621e1ba5b0f1c6bec76eb9c20784c143ed9812 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,16 +20,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] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell name: Check source code spelling args: [-L assertIn] exclude: ^(swh/indexer/data/) - 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 b08c3882b9c539a5a74a1653cbc7107a6fdb0817..0000000000000000000000000000000000000000 --- a/mypy.ini +++ /dev/null @@ -1,37 +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-confluent_kafka.*] -ignore_missing_imports = True - -[mypy-iso8601.*] -ignore_missing_imports = True - -[mypy-magic.*] -ignore_missing_imports = True - -[mypy-pkg_resources.*] -ignore_missing_imports = True - -[mypy-psycopg2.*] -ignore_missing_imports = True - -[mypy-pybtex.*] -ignore_missing_imports = True - -[mypy-pyld.*] -ignore_missing_imports = True - -[mypy-rdflib.*] -ignore_missing_imports = True - -[mypy-xmltodict.*] -ignore_missing_imports = True - -# [mypy-add_your_lib_here.*] -# ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 74672064c613131ceb8cb7d0f82aab27387271a8..2e9bd3eb637459468768a8cc13a3329b647ef7cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,3 +59,35 @@ 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 = [ + "pybtex.*", + "pyld.*", +] +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] +norecursedirs = "build docs .*" +asyncio_mode = "strict" +consider_namespace_packages = true diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index fe398a0babf5a774f332240c7ce22d38f7330ba1..0000000000000000000000000000000000000000 --- a/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -norecursedirs = build docs .* -asyncio_mode = strict -consider_namespace_packages = true diff --git a/requirements-test.txt b/requirements-test.txt index 1372615ef55f6c59be1d4920fd16fb65d8544ba1..02475ed8bbc944191bb13c8ad20f2897d8e60cfa 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,4 +6,6 @@ swh.core[testing] >= 3.0.0 swh.storage[testing] >= 2.0.0 types-click +types-confluent-kafka types-pyyaml +types-xmltodict 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/indexer/metadata_dictionary/codemeta.py b/swh/indexer/metadata_dictionary/codemeta.py index 86d0ae5038d1f578e2d0d25b273c86ed7579ed16..1210e4289d4a45fa02a9452a0b80c278959436f2 100644 --- a/swh/indexer/metadata_dictionary/codemeta.py +++ b/swh/indexer/metadata_dictionary/codemeta.py @@ -231,4 +231,4 @@ class JsonSwordCodemetaMapping(SwordCodemetaMapping): # Root tag was stripped by swh-deposit json_doc = {"entry": json_doc} - return super().translate(xmltodict.unparse(json_doc)) + return super().translate(xmltodict.unparse(json_doc).encode()) diff --git a/tox.ini b/tox.ini index 11aaae71cab3f43f75d7ceec899f02f0616f6ffe..deb03597b55404009bfeadf548522112a01c068a 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ commands = [testenv:black] skip_install = true deps = - black==24.8.0 + black==25.1.0 commands = {envpython} -m black --check swh @@ -32,8 +32,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 @@ -41,7 +43,7 @@ commands = extras = testing deps = - mypy==1.11.1 + mypy==1.15.0 commands = mypy swh