]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update lint setup
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Nov 2025 21:32:54 +0000 (16:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Nov 2025 23:14:48 +0000 (18:14 -0500)
We are stuck on flake8 because we rely on many plugins with
specific behaviors.  The situation has calcified where:

1. the whole world uses ruff
2. nobody cares about import order linting or all the other stuff
   we do, and/or similar but not quite the same things are embedded
   deeply into ruff which would require us giving up a lot of our
   standards (like isort)
3. flake8 is absolutely never going to support pyproject.
4. flake8-pyproject works for this

beyond that, for t string support we want to make it easy
to get onto py3.14, so here we update black to the latest which
appears to fix some missing symbols for py3.14 t strings.

we should also migrate the remaining sqlalchemy test config
from setup.cfg to pyproject.toml but that should likely be
2.1 only

Change-Id: I896a7c839148d0ef516728c73baddc8eddf5ee96
(cherry picked from commit f6714c8e090b9dd84ac4256ed74eefc1fe9cbddc)

.pre-commit-config.yaml
noxfile.py
pyproject.toml
setup.cfg
tox.ini

index 8d730ca2d41fe27113b8bd1abbd0bad8be3812c7..eb11bc7a5b1355d0e77aaac3de80c6f83d493def 100644 (file)
@@ -2,7 +2,7 @@
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
 -   repo: https://github.com/python/black
-    rev: 25.9.0
+    rev: 25.11.0
     hooks:
     -   id: black
 
@@ -15,7 +15,9 @@ repos:
     rev: 7.3.0
     hooks:
     -   id: flake8
+        entry: python -m flake8p
         additional_dependencies:
+          - flake8-pyproject
           - flake8-import-order>=0.19.2
           - flake8-import-single==0.1.5
           - flake8-builtins
index d230efee5df737d0ac8ef97686eae8f8b4f402e9..29a526d3376ef0d11e00afe11a3b9f6fd41e2b6d 100644 (file)
@@ -366,9 +366,12 @@ def test_pep8(session: nox.Session) -> None:
     session.install(*nox.project.dependency_groups(pyproject, "lint"))
 
     for cmd in [
-        "flake8 ./lib/ ./test/ ./examples/ noxfile.py "
+        "flake8p ./lib/ ./test/ ./examples/ noxfile.py "
         "setup.py doc/build/conf.py",
-        "flake8  --extend-ignore='' ./lib/sqlalchemy/ext/asyncio "
+        # run "unused argument" lints on asyncio, as we have a lot of
+        # proxy methods here
+        "flake8p  --ignore='' --select='U100,U101' "
+        "./lib/sqlalchemy/ext/asyncio "
         "./lib/sqlalchemy/orm/scoping.py",
         "black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py",
         "slotscheck -m sqlalchemy",
index cd04723ea28a080d1b0b0403cfa465abe21c9fa9..d08ef2fc93b0a13ebb949b0fa0efd05b3bb4c7fc 100644 (file)
@@ -78,7 +78,8 @@ tests-mssql-asyncio = [
 
 lint = [
     {include-group = "tests-greenlet"},
-    "flake8>=7.2.0",
+    "flake8>=7.3.0",
+    "flake8-pyproject",
     "flake8-import-order>=0.19.2",
     "flake8-import-single==0.1.5",
     "flake8-builtins",
@@ -88,7 +89,7 @@ lint = [
     "flake8-rst-docstrings",
     "pydocstyle<4.0.0",
     "pygments",
-    "black==25.1.0",
+    "black==25.11.0",
     "slotscheck>=0.17.0",
     "zimports>=0.6.3",  # required by generate_tuple_map_overloads
 ]
@@ -109,6 +110,41 @@ target-version = ['py37']
 [tool.zimports]
 black-line-length = 79
 
+
+[tool.flake8]
+show-source = false
+enable-extensions = "G"
+
+# E203 is due to https://github.com/PyCQA/pycodestyle/issues/373
+ignore = [
+    "A003","A005",
+    "D",
+    "E203","E305","E701","E704","E711","E712","E721","E722","E741",
+    "I300",
+    "N801","N802","N806",
+    "RST304","RST303","RST299","RST399",
+    "W503","W504","W601",
+    "U100","U101"
+]
+
+exclude = [".venv",".git",".tox","dist","doc","*egg","build"]
+import-order-style = "google"
+application-import-names = ["sqlalchemy","test"]
+per-file-ignores =[
+    "**/__init__.py:F401",
+    "test/*:FA100",
+    "test/typing/plain_files/*:F821,E501,FA100",
+    "test/ext/mypy/plugin_files/*:F821,E501,FA100",
+    "lib/sqlalchemy/events.py:F401",
+    "lib/sqlalchemy/schema.py:F401",
+    "lib/sqlalchemy/types.py:F401",
+    "lib/sqlalchemy/sql/expression.py:F401",
+    "lib/sqlalchemy/util/typing.py:F401"
+]
+
+unused-arguments-ignore-stub-functions=true
+unused-arguments-ignore-dunder=true
+
 [tool.slotscheck]
 exclude-modules = '''
 ^sqlalchemy\.(
index 241bf8ab1d9ec5e68ce33b88cc260555f13aa2d2..8604d7e0df90d6536309c303b3492d409168c44e 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -99,39 +99,6 @@ where = lib
 sign = 1
 identity = C4DAFEE1
 
-[flake8]
-show-source = false
-enable-extensions = G
-
-# E203 is due to https://github.com/PyCQA/pycodestyle/issues/373
-ignore =
-    A003,A005
-    D,
-    E203,E305,E701,E704,E711,E712,E721,E722,E741,
-    I300,
-    N801,N802,N806,
-    RST304,RST303,RST299,RST399,
-    W503,W504,W601
-extend-ignore =
-    # keep in extend ignore so that they can be enabled in a subset of files in the tox run
-    U100,U101
-exclude = .venv,.git,.tox,dist,doc,*egg,build
-import-order-style = google
-application-import-names = sqlalchemy,test
-per-file-ignores =
-    **/__init__.py:F401
-    test/*:FA100
-    test/typing/plain_files/*:F821,E501,FA100
-    test/ext/mypy/plugin_files/*:F821,E501,FA100
-    lib/sqlalchemy/events.py:F401
-    lib/sqlalchemy/schema.py:F401
-    lib/sqlalchemy/types.py:F401
-    lib/sqlalchemy/sql/expression.py:F401
-    lib/sqlalchemy/util/typing.py:F401
-
-unused-arguments-ignore-stub-functions=true
-unused-arguments-ignore-dunder=true
-
 [sqla_testing]
 requirement_cls = test.requirements:DefaultRequirements
 profile_file = test/profiles.txt
diff --git a/tox.ini b/tox.ini
index 2359df1d9db79c37b4e2f5df3fe56e5d7f72ad97..322b1db0e9c72a1fa7a0daf7b6a80b3134519527 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -250,6 +250,7 @@ extras=
      {[greenletextras]extras}
 
 deps=
+      flake8-pyproject
       flake8>=7.3.0
       flake8-import-order>=0.19.2
       flake8-builtins
@@ -262,7 +263,7 @@ deps=
       # in case it requires a version pin
       pydocstyle
       pygments
-      black==25.9.0
+      black==25.11.0
       slotscheck>=0.17.0
 
       # required by generate_tuple_map_overloads
@@ -272,9 +273,12 @@ allowlist_externals =
     git
     sh
 commands =
-     flake8 ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
-     # run flake8-unused-arguments only on some files / modules
-     flake8  --extend-ignore='' ./lib/sqlalchemy/ext/asyncio ./lib/sqlalchemy/orm/scoping.py
+     flake8p ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
+
+     # run "unused argument" lints on asyncio, as we have a lot of
+     # proxy methods here
+     flake8p  --ignore='' --select='U100,U101' ./lib/sqlalchemy/ext/asyncio ./lib/sqlalchemy/orm/scoping.py
+
      black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py
      # test with cython and without cython exts running
      slotscheck -m sqlalchemy