]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add flake8-unused-arguments to catch unused args typos
authorFederico Caselli <cfederico87@gmail.com>
Wed, 27 Sep 2023 19:01:57 +0000 (21:01 +0200)
committermike bayer <mike_mp@zzzcomputing.com>
Fri, 29 Sep 2023 16:21:07 +0000 (16:21 +0000)
Change-Id: I85447bf6587074c521c3673d2999a7ce05fefaec

.pre-commit-config.yaml
lib/sqlalchemy/ext/asyncio/base.py
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/asyncio/session.py
setup.cfg
tox.ini

index 7f12edcf072405712858da846c463824b8dd17b6..ab722e4f3092adec3bcb90d383ec5bb8c5fd80a1 100644 (file)
@@ -21,6 +21,7 @@ repos:
           - flake8-builtins
           - flake8-future-annotations>=0.0.5
           - flake8-docstrings>=1.6.0
+          - flake8-unused-arguments
           - flake8-rst-docstrings
           # flake8-rst-docstrings dependency, leaving it here
           # in case it requires a version pin
index 1c8707c780ad396958991ec3f0eeaa1f2c0c687d..251f52125424252b07ff6fb2bcc20eec714db3b5 100644 (file)
@@ -68,7 +68,7 @@ class ReversibleProxy(Generic[_PT]):
     def _target_gced(
         cls,
         ref: weakref.ref[_PT],
-        proxy_ref: Optional[weakref.ref[Self]] = None,
+        proxy_ref: Optional[weakref.ref[Self]] = None,  # noqa: U100
     ) -> None:
         cls._proxy_objects.pop(ref, None)
 
index deab97f6595fb7df41332bb4cec7336ad89ff7ac..bf968cc38848dafe7a5642facdf1bcc27eac774e 100644 (file)
@@ -257,7 +257,9 @@ class AsyncConnection(
             AsyncEngine._retrieve_proxy_for_target(target.engine), target
         )
 
-    async def start(self, is_ctxmanager: bool = False) -> AsyncConnection:
+    async def start(
+        self, is_ctxmanager: bool = False  # noqa: U100
+    ) -> AsyncConnection:
         """Start this :class:`_asyncio.AsyncConnection` object's context
         outside of using a Python ``with:`` block.
 
@@ -1442,7 +1444,9 @@ def _get_sync_engine_or_connection(
 
 
 @inspection._inspects(AsyncConnection)
-def _no_insp_for_async_conn_yet(subject: AsyncConnection) -> NoReturn:
+def _no_insp_for_async_conn_yet(
+    subject: AsyncConnection,  # noqa: U100
+) -> NoReturn:
     raise exc.NoInspectionAvailable(
         "Inspection on an AsyncConnection is currently not supported. "
         "Please use ``run_sync`` to pass a callable where it's possible "
@@ -1452,7 +1456,9 @@ def _no_insp_for_async_conn_yet(subject: AsyncConnection) -> NoReturn:
 
 
 @inspection._inspects(AsyncEngine)
-def _no_insp_for_async_engine_xyet(subject: AsyncEngine) -> NoReturn:
+def _no_insp_for_async_engine_xyet(
+    subject: AsyncEngine,  # noqa: U100
+) -> NoReturn:
     raise exc.NoInspectionAvailable(
         "Inspection on an AsyncEngine is currently not supported. "
         "Please obtain a connection then use ``conn.run_sync`` to pass a "
index da69c4fb3efc651d6a6354f211a6d46866008130..c97e40723d562391a74faccb251b67ceec229ce0 100644 (file)
@@ -609,6 +609,7 @@ class AsyncSession(ReversibleProxy[Session]):
             populate_existing=populate_existing,
             with_for_update=with_for_update,
             identity_token=identity_token,
+            execution_options=execution_options,
         )
         return result_obj
 
index bcfa98116bfdd75433e09dd69790e8e698af6e5a..6bd9cf59bc90d91bb823025d891ff7156b806f06 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -107,6 +107,9 @@ ignore =
     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
@@ -121,6 +124,9 @@ per-file-ignores =
     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 1e0a5769832641131de8e5f39b8cb3d22ae04d72..c4e9e735f55daf9c6553cc6a1674093799c3e7f1 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -215,8 +215,9 @@ deps=
       flake8-builtins
       flake8-future-annotations>=0.0.5
       flake8-docstrings>=1.6.0
-      flake8-rst-docstrings
       flake8-import-single==0.1.5
+      flake8-unused-arguments
+      flake8-rst-docstrings
       # flake8-rst-docstrings dependency, leaving it here
       # in case it requires a version pin
       pydocstyle
@@ -232,6 +233,8 @@ allowlist_externals =
     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
      black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py
      # test with cython and without cython exts running
      slotscheck -m sqlalchemy