]> 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 22:16:52 +0000 (17:16 -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

.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 a548f44c9b1ed7e72f8b96c62b74f1b0c9b778c1..b025d0852051bf1d6f47aead370dbe24237a1fbf 100644 (file)
@@ -355,9 +355,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 c109841cbd56b804f6076c250e25a8f326db05d4..fda3fe957318c6dc0dc4f8a9f48153f88055164d 100644 (file)
@@ -172,7 +172,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",
@@ -182,7 +183,7 @@ lint = [
     "flake8-rst-docstrings",
     "pydocstyle<4.0.0",
     "pygments",
-    "black==25.9.0",
+    "black==25.11.0",
     "slotscheck>=0.17.0",
     "zimports>=0.6.3",  # required by generate_tuple_map_overloads
 ]
@@ -234,6 +235,39 @@ target-version = ['py310']
 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",
+    "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\.testing
index d66134a10f95c15d1905fa71b0c929408045256b..4bbe7d0aab0c0f431280519fcae769d0b0776598 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,34 +1,3 @@
-[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
-    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
diff --git a/tox.ini b/tox.ini
index a20bf25642bfeeda659f3243eb48eae636673a5f..f59a600c8629b9ad2d52471e8417aac7c41abb95 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -249,6 +249,7 @@ extras=
      {[greenletextras]extras}
 
 deps=
+      flake8-pyproject
       flake8>=7.3.0
       flake8-import-order>=0.19.2
       flake8-builtins
@@ -261,7 +262,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
@@ -271,9 +272,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
      slotscheck -m sqlalchemy
      python ./tools/format_docs_code.py --check