From 281c463c3937e1a7050ca2ba75695f6f78d04d6a Mon Sep 17 00:00:00 2001
From: Antoine Lambert <anlambert@softwareheritage.org>
Date: Fri, 14 Feb 2025 15:01:05 +0100
Subject: [PATCH 1/3] 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                | 23 -----------------------
 pyproject.toml          | 31 +++++++++++++++++++++++++++++++
 pytest.ini              |  9 ---------
 requirements-test.txt   |  1 +
 setup.cfg               |  8 --------
 tox.ini                 |  8 +++++---
 8 files changed, 44 insertions(+), 50 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 ce657ea..3fe7bcb 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 Loader SVN
 distribution_name: swh-loader-svn
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index cf69895..e777d35 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,14 +20,14 @@ 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]
+        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 28bf5ac..0000000
--- a/mypy.ini
+++ /dev/null
@@ -1,23 +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-celery.*]
-ignore_missing_imports = True
-
-[mypy-iso8601.*]
-ignore_missing_imports = True
-
-[mypy-pkg_resources.*]
-ignore_missing_imports = True
-
-[mypy-pytest.*]
-ignore_missing_imports = True
-
-[mypy-subvertpy.*]
-ignore_missing_imports = True
diff --git a/pyproject.toml b/pyproject.toml
index 26eccaf..b9c62ce 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -56,3 +56,34 @@ 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 = [
+    "subvertpy.*",
+]
+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 88b203f..0000000
--- a/pytest.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[pytest]
-norecursedirs = build docs .*
-asyncio_mode = strict
-consider_namespace_packages = true
-
-# Drop this when these fixtures aren't imported automatically
-addopts = -p no:pytest_swh_scheduler -p no:pytest_swh_storage
-markers =
-    fs: execute tests that write to the filesystem
diff --git a/requirements-test.txt b/requirements-test.txt
index e609047..c04a504 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,3 +1,4 @@
+celery-types
 pytest >= 8.1
 pytest-mock
 pytest-postgresql
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index adf9af3..0000000
--- 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/tox.ini b/tox.ini
index d1dc6b9..0a605f5 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
 
-- 
GitLab


From d9060986f142a3f5329a67ca05987f33ce09ff91 Mon Sep 17 00:00:00 2001
From: Antoine Lambert <anlambert@softwareheritage.org>
Date: Fri, 14 Feb 2025 15:01:34 +0100
Subject: [PATCH 2/3] directory, replay: Fix black formatting

---
 swh/loader/svn/directory.py | 4 +---
 swh/loader/svn/replay.py    | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/swh/loader/svn/directory.py b/swh/loader/svn/directory.py
index 6b94594..7b568e7 100644
--- a/swh/loader/svn/directory.py
+++ b/swh/loader/svn/directory.py
@@ -3,9 +3,7 @@
 # License: GNU General Public License version 3, or any later version
 # See top-level LICENSE file for more information
 
-"""Loader in charge of injecting tree at a specific revision.
-
-"""
+"""Loader in charge of injecting tree at a specific revision."""
 
 from datetime import datetime
 import os
diff --git a/swh/loader/svn/replay.py b/swh/loader/svn/replay.py
index 8b542e8..9d6ec21 100644
--- a/swh/loader/svn/replay.py
+++ b/swh/loader/svn/replay.py
@@ -3,9 +3,7 @@
 # License: GNU General Public License version 3, or any later version
 # See top-level LICENSE file for more information
 
-"""Remote Access client to svn server.
-
-"""
+"""Remote Access client to svn server."""
 
 from __future__ import annotations
 
-- 
GitLab


From 001c1361bd9fa464d9463499d618a275400f6baa Mon Sep 17 00:00:00 2001
From: Antoine Lambert <anlambert@softwareheritage.org>
Date: Fri, 14 Feb 2025 15:02:29 +0100
Subject: [PATCH 3/3] test_loader: Fix flake8 warning

---
 swh/loader/svn/tests/test_loader.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/swh/loader/svn/tests/test_loader.py b/swh/loader/svn/tests/test_loader.py
index 420ac5c..af49c31 100644
--- a/swh/loader/svn/tests/test_loader.py
+++ b/swh/loader/svn/tests/test_loader.py
@@ -1965,7 +1965,7 @@ def test_loader_with_subprojects(
     for i in range(1, 4):
         # load each project in the repository separately and check behavior
         # is the same if origin URL has a trailing slash or not
-        origin_url = f"{repo_url}/projects/project{i}{'/' if i%2 else ''}"
+        origin_url = f"{repo_url}/projects/project{i}{'/' if i % 2 else ''}"
 
         loader_params = {
             "storage": swh_storage,
-- 
GitLab