From: Federico Caselli Date: Wed, 27 Sep 2023 19:01:57 +0000 (+0200) Subject: Add flake8-unused-arguments to catch unused args typos X-Git-Tag: rel_2_0_22~20^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e8acd7a65ca9b0c836470f66b127e2397537d87;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add flake8-unused-arguments to catch unused args typos Change-Id: I85447bf6587074c521c3673d2999a7ce05fefaec --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f12edcf07..ab722e4f30 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/lib/sqlalchemy/ext/asyncio/base.py b/lib/sqlalchemy/ext/asyncio/base.py index 1c8707c780..251f521254 100644 --- a/lib/sqlalchemy/ext/asyncio/base.py +++ b/lib/sqlalchemy/ext/asyncio/base.py @@ -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) diff --git a/lib/sqlalchemy/ext/asyncio/engine.py b/lib/sqlalchemy/ext/asyncio/engine.py index deab97f659..bf968cc388 100644 --- a/lib/sqlalchemy/ext/asyncio/engine.py +++ b/lib/sqlalchemy/ext/asyncio/engine.py @@ -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 " diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index da69c4fb3e..c97e40723d 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -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 diff --git a/setup.cfg b/setup.cfg index bcfa98116b..6bd9cf59bc 100644 --- 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 1e0a576983..c4e9e735f5 100644 --- 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