]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update flake8 noqa skips with proper syntax
authorFederico Caselli <cfederico87@gmail.com>
Mon, 11 Apr 2022 20:21:20 +0000 (22:21 +0200)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Apr 2022 21:29:40 +0000 (17:29 -0400)
Change-Id: I42ed77f559e3ee5b8c600d98457ee37803ef0ea6
(cherry picked from commit 139c6ec0fb1f930be9b64545262d2580f6cbc83e)

24 files changed:
lib/sqlalchemy/dialects/oracle/provision.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/ext/asyncio/scoping.py
lib/sqlalchemy/ext/asyncio/session.py
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/sql/dml.py
lib/sqlalchemy/sql/functions.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/util/concurrency.py
lib/sqlalchemy/util/langhelpers.py
test/aaa_profiling/test_orm.py
test/engine/test_execute.py
test/ext/mypy/files/ensure_descriptor_type_fully_inferred.py
test/ext/mypy/files/ensure_descriptor_type_noninferred.py
test/ext/mypy/files/ensure_descriptor_type_semiinferred.py
test/ext/mypy/files/invalid_noninferred_lh_type.py
test/ext/mypy/files/typeless_fk_col_cant_infer.py
test/ext/mypy/test_mypy_plugin_py3k.py
test/orm/test_deprecations.py
test/sql/test_functions.py

index 8ce58782be0c761165a1191aa7a6ab6e0d79cf42..74ad1f2a4b1223e0d7e19a8097c7c12bef3e5675 100644 (file)
@@ -63,7 +63,7 @@ def stop_test_class_outside_fixtures(config, db, cls):
     try:
         with db.begin() as conn:
             # run magic command to get rid of identity sequences
-            # https://floo.bar/2019/11/29/drop-the-underlying-sequence-of-an-identity-column/  # noqa E501
+            # https://floo.bar/2019/11/29/drop-the-underlying-sequence-of-an-identity-column/  # noqa: E501
             conn.exec_driver_sql("purge recyclebin")
     except exc.DatabaseError as err:
         log.warning("purge recyclebin command failed: %s", err)
index 4f63002bc9bc897b2357fa3117d80af5aa0e8a40..bbc64cf710affd6c3e924861ea7d53c46f9187fb 100644 (file)
@@ -1421,7 +1421,7 @@ E.g.::
     )
 
 
-"""  # noqa E501
+"""  # noqa: E501
 
 from collections import defaultdict
 import datetime as dt
index abe42c96ad883bdf4c56311c7f1564d16fb972da..e17422e1c312eb2816327faf506e186cf50b972f 100644 (file)
@@ -1683,7 +1683,7 @@ class BaseCursorResult(object):
 
             :ref:`tutorial_update_delete_rowcount` - in the :ref:`unified_tutorial`
 
-        """  # noqa E501
+        """  # noqa: E501
 
         try:
             return self.context.rowcount
index 46c8f0baa77a07a1eba44b5093b03c0555ea90c8..8eca8c52480d264f2c6095248689d0ccaa8163b6 100644 (file)
@@ -85,7 +85,7 @@ class async_scoped_session(ScopedSessionMixin):
          the current scope.   A function such as ``asyncio.current_task``
          may be useful here.
 
-        """  # noqa E501
+        """  # noqa: E501
 
         self.session_factory = session_factory
         self.registry = ScopedRegistry(session_factory, scopefunc)
index 0b428d7feddad672a028a463af01c41fee757894..53ebbc00978dff3a069bac9fbb352181d374555e 100644 (file)
@@ -503,7 +503,7 @@ class AsyncSession(ReversibleProxy):
         blocking-style code, which will be translated to implicitly async calls
         at the point of invoking IO on the database drivers.
 
-        """  # noqa E501
+        """  # noqa: E501
 
         return self.sync_session.get_bind(
             mapper=mapper, clause=clause, bind=bind, **kw
index 42419e48cde78dcf35b92abd61415724dec683ed..4b6c710c72d334105dc7bf463e31e2a5f279961b 100644 (file)
@@ -200,7 +200,7 @@ class declared_attr(interfaces._MappedAttribute, property):
         :ref:`orm_declarative_dataclasses_mixin` - illustrates special forms
         for use with Python dataclasses
 
-    """  # noqa E501
+    """  # noqa: E501
 
     def __init__(self, fget, cascading=False):
         super(declared_attr, self).__init__(fget)
index 7dee717c68d9840ac95eadd925108b7478ffa791..b5691c0c9782ada12e1700b22678c2d2b62a0b23 100644 (file)
@@ -758,7 +758,7 @@ def _instance_processor(
                         # test.orm.inheritance.test_basic ->
                         # EagerTargetingTest.test_adapt_stringency
                         # OptimizedLoadTest.test_column_expression_joined
-                        # PolymorphicOnNotLocalTest.test_polymorphic_on_column_prop  # noqa E501
+                        # PolymorphicOnNotLocalTest.test_polymorphic_on_column_prop  # noqa: E501
                         #
 
                         adapted_col = adapter.columns[col]
index 943bb07054601d0363dfe2f821f72b981bdffa70..4f3280373bdef941f8a1abf8fe77d71fb656198c 100644 (file)
@@ -439,7 +439,7 @@ class UpdateBase(
 
           :ref:`tutorial_insert_returning` - in the :ref:`unified_tutorial`
 
-        """  # noqa E501
+        """  # noqa: E501
         if self._return_defaults:
             raise exc.InvalidRequestError(
                 "return_defaults() is already configured on this statement"
@@ -578,7 +578,7 @@ class UpdateBase(
 
             :ref:`queryguide_inspection` - ORM background
 
-        """  # noqa E501
+        """  # noqa: E501
         meth = DMLState.get_plugin_class(
             self
         ).get_returning_column_descriptions
index e0ff1655f9f0e8ec6ed52f185881a3fbeae14738..584782b28186287db1b0a1d143967fcfa611a6c4 100644 (file)
@@ -167,7 +167,7 @@ class FunctionElement(Executable, ColumnElement, FromClause, Generative):
 
             :meth:`_functions.FunctionElement.column_valued`
 
-        """  # noqa E501
+        """  # noqa: E501
 
         return ScalarFunctionColumn(self, name, type_)
 
@@ -237,7 +237,7 @@ class FunctionElement(Executable, ColumnElement, FromClause, Generative):
             :meth:`_sql.TableValuedAlias.render_derived` - renders the alias
             using a derived column clause, e.g. ``AS name(col1, col2, ...)``
 
-        """  # noqa 501
+        """  # noqa: 501
 
         new_func = self._generate()
 
@@ -280,7 +280,7 @@ class FunctionElement(Executable, ColumnElement, FromClause, Generative):
 
             :meth:`_functions.FunctionElement.table_valued`
 
-        """  # noqa 501
+        """  # noqa: 501
 
         return self.alias(name=name).column
 
@@ -305,7 +305,7 @@ class FunctionElement(Executable, ColumnElement, FromClause, Generative):
             :meth:`_functions.FunctionElement.table_valued` - generates table-valued
             SQL function expressions.
 
-        """  # noqa E501
+        """  # noqa: E501
 
         return ColumnCollection(
             columns=[(col.key, col) for col in self._all_selected_columns]
@@ -1170,19 +1170,19 @@ class coalesce(ReturnTypeFromArgs):
     inherit_cache = True
 
 
-class max(ReturnTypeFromArgs):  # noqa  A001
+class max(ReturnTypeFromArgs):  # noqa:  A001
     """The SQL MAX() aggregate function."""
 
     inherit_cache = True
 
 
-class min(ReturnTypeFromArgs):  # noqa A001
+class min(ReturnTypeFromArgs):  # noqa: A001
     """The SQL MIN() aggregate function."""
 
     inherit_cache = True
 
 
-class sum(ReturnTypeFromArgs):  # noqa A001
+class sum(ReturnTypeFromArgs):  # noqa: A001
     """The SQL SUM() aggregate function."""
 
     inherit_cache = True
index 621efd36ce196f0ba8368913b9b0874b7fd9d7fd..d91e4e1661d23ada152c7bba8c613e2c12f71f1d 100644 (file)
@@ -1661,7 +1661,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause):
                 parameter to :class:`_schema.Column`.
 
 
-        """  # noqa E501
+        """  # noqa: E501, RST201, RST202
 
         name = kwargs.pop("name", None)
         type_ = kwargs.pop("type_", None)
index ea81ce67058bebd48910399e537bb8ee340c12c5..740085043c39af495bcb4959b43c138bf2c6f7b5 100644 (file)
@@ -889,7 +889,7 @@ LABEL_STYLE_NONE = util.symbol(
 
     .. versionadded:: 1.4
 
-""",  # noqa E501
+""",  # noqa: E501
 )
 
 LABEL_STYLE_TABLENAME_PLUS_COL = util.symbol(
@@ -919,7 +919,7 @@ LABEL_STYLE_TABLENAME_PLUS_COL = util.symbol(
 
     .. versionadded:: 1.4
 
-""",  # noqa E501
+""",  # noqa: E501
 )
 
 
@@ -1757,7 +1757,7 @@ class TableValuedAlias(Alias):
 
         :ref:`tutorial_functions_table_valued` - in the :ref:`unified_tutorial`
 
-    """  # noqa E501
+    """  # noqa: E501
 
     __visit_name__ = "table_valued_alias"
 
@@ -1884,7 +1884,7 @@ class TableValuedAlias(Alias):
          datatype specification with each column. This is a special syntax
          currently known to be required by PostgreSQL for some SQL functions.
 
-        """  # noqa E501
+        """  # noqa: E501
 
         # note: don't use the @_generative system here, keep a reference
         # to the original object.  otherwise you can have re-use of the
@@ -5897,7 +5897,7 @@ class Select(
 
          .. versionadded:: 1.4.23
 
-        """  # noqa E501
+        """  # noqa: E501
 
         # memoizations should be cleared here as of
         # I95c560ffcbfa30b26644999412fb6a385125f663 , asserting this
@@ -6709,7 +6709,7 @@ class Exists(UnaryExpression):
             :meth:`_sql.SelectBase.exists` - method to transform a ``SELECT`` to an
             ``EXISTS`` clause.
 
-        """  # noqa E501
+        """  # noqa: E501
         if args and isinstance(args[0], (SelectBase, ScalarSelect)):
             s = args[0]
         else:
index ce1b5d3c1c3e338eedcf1a9f2f1ea8a32e7698b0..49e3cefb41337ad25595af07506caa3abc44bb4d 100644 (file)
@@ -1386,7 +1386,7 @@ class SuiteRequirements(Requirements):
     def greenlet(self):
         def go(config):
             try:
-                import greenlet  # noqa F401
+                import greenlet  # noqa: F401
             except ImportError:
                 return False
             else:
index 9eb44f4657e170c4ba99b6136e8705952c641d53..e900b437e7ff730bfccef2bd171c7cfe5ec13b0f 100644 (file)
@@ -12,7 +12,7 @@ greenlet_error = None
 
 if compat.py3k:
     try:
-        import greenlet  # noqa F401
+        import greenlet  # noqa: F401
     except ImportError as e:
         greenlet_error = str(e)
     else:
@@ -22,18 +22,18 @@ if compat.py3k:
         from ._concurrency_py3k import greenlet_spawn
         from ._concurrency_py3k import is_exit_exception
         from ._concurrency_py3k import AsyncAdaptedLock
-        from ._concurrency_py3k import _util_async_run  # noqa F401
+        from ._concurrency_py3k import _util_async_run  # noqa: F401
         from ._concurrency_py3k import (
             _util_async_run_coroutine_function,
-        )  # noqa F401, E501
-        from ._concurrency_py3k import asyncio  # noqa F401
+        )  # noqa: F401, E501
+        from ._concurrency_py3k import asyncio  # noqa: F401
 
     # does not need greennlet, just Python 3
-    from ._compat_py3k import asynccontextmanager  # noqa F401
+    from ._compat_py3k import asynccontextmanager  # noqa: F401
 
 if not have_greenlet:
 
-    asyncio = None  # noqa F811
+    asyncio = None  # noqa: F811
 
     def _not_implemented():
         # this conditional is to prevent pylance from considering
@@ -51,23 +51,23 @@ if not have_greenlet:
                 else ""
             )
 
-    def is_exit_exception(e):  # noqa F811
+    def is_exit_exception(e):  # noqa: F811
         return not isinstance(e, Exception)
 
-    def await_only(thing):  # noqa F811
+    def await_only(thing):  # noqa: F811
         _not_implemented()
 
-    def await_fallback(thing):  # noqa F81
+    def await_fallback(thing):  # noqa: F811
         return thing
 
-    def greenlet_spawn(fn, *args, **kw):  # noqa F81
+    def greenlet_spawn(fn, *args, **kw):  # noqa: F811
         _not_implemented()
 
-    def AsyncAdaptedLock(*args, **kw):  # noqa F81
+    def AsyncAdaptedLock(*args, **kw):  # noqa: F811
         _not_implemented()
 
-    def _util_async_run(fn, *arg, **kw):  # noqa F81
+    def _util_async_run(fn, *arg, **kw):  # noqa: F811
         return fn(*arg, **kw)
 
-    def _util_async_run_coroutine_function(fn, *arg, **kw):  # noqa F81
+    def _util_async_run_coroutine_function(fn, *arg, **kw):  # noqa: F811
         _not_implemented()
index 68074dc3354c52e21a834625dbdb10adfdc6b9f1..8d5de1831404d6ef05996e1eea689d7d9f593355 100644 (file)
@@ -668,7 +668,7 @@ def create_proxy_methods(
             else:
                 code = (
                     "def %(name)s(%(args)s):\n"
-                    "    return %(self_arg)s._proxied.%(name)s(%(apply_kw_proxied)s)"  # noqa E501
+                    "    return %(self_arg)s._proxied.%(name)s(%(apply_kw_proxied)s)"  # noqa: E501
                     % metadata
                 )
 
@@ -1932,9 +1932,9 @@ def repr_tuple_names(names):
 
 def has_compiled_ext():
     try:
-        from sqlalchemy import cimmutabledict  # noqa F401
-        from sqlalchemy import cprocessors  # noqa F401
-        from sqlalchemy import cresultproxy  # noqa F401
+        from sqlalchemy import cimmutabledict  # noqa: F401
+        from sqlalchemy import cprocessors  # noqa: F401
+        from sqlalchemy import cresultproxy  # noqa: F401
 
         return True
     except ImportError:
index 65b1547a1831548f9ce814101b4fef20ee91c4a3..bbcb6ad5b8b49da83f8f0061e34a5d6716a47e33 100644 (file)
@@ -1227,7 +1227,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1243,7 +1243,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1257,7 +1257,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1271,7 +1271,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1286,7 +1286,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1301,7 +1301,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1315,7 +1315,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1330,7 +1330,7 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
 
@@ -1344,6 +1344,6 @@ class AnnotatedOverheadTest(NoCache, fixtures.MappedTest):
             for i in range(100):
                 # test counts assume objects remain in the session
                 # from previous run
-                r = q.all()  # noqa F841
+                r = q.all()  # noqa: F841
 
         go()
index 2a61bd1f636436cecbf38f6497b1b91e6fcede0f..afb7ddd4d41fc56e7428c84cd9c3bc2620c2a3b9 100644 (file)
@@ -471,7 +471,7 @@ class ExecuteTest(fixtures.TablesTest):
             eq_(str(err), message)
 
             # unicode accessor decodes to utf-8
-            eq_(unicode(err), util.u("some message méil"))  # noqa F821
+            eq_(unicode(err), util.u("some message méil"))  # noqa: F821
         else:
             eq_(str(err), util.u("some message méil"))
 
@@ -486,7 +486,7 @@ class ExecuteTest(fixtures.TablesTest):
             eq_(str(err), message)
 
             # unicode accessor decodes to utf-8
-            eq_(unicode(err), util.u("some message m\\xe9il"))  # noqa F821
+            eq_(unicode(err), util.u("some message m\\xe9il"))  # noqa: F821
         else:
             eq_(str(err), util.u("some message m\\xe9il"))
 
@@ -497,7 +497,7 @@ class ExecuteTest(fixtures.TablesTest):
 
         err = tsa.exc.SQLAlchemyError(message)
         if util.py2k:
-            eq_(unicode(err), util.u("some message méil"))  # noqa F821
+            eq_(unicode(err), util.u("some message méil"))  # noqa: F821
         else:
             eq_(str(err), util.u("some message méil"))
 
@@ -506,7 +506,7 @@ class ExecuteTest(fixtures.TablesTest):
         eq_(str(err), "foo")
 
         if util.py2k:
-            eq_(unicode(err), util.u("fóó"))  # noqa F821
+            eq_(unicode(err), util.u("fóó"))  # noqa: F821
 
     def test_stmt_exception_str_multi_args(self):
         err = tsa.exc.SQLAlchemyError("some message", 206)
index 1a89041474b499262a9fd2e692be72ab15be9363..9ee9c76f46720cfcfb378ff3cba75e128ff3779a 100644 (file)
@@ -16,5 +16,5 @@ class User:
 
 u1 = User()
 
-# EXPECTED_MYPY: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  # noqa E501
+# EXPECTED_MYPY: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  # noqa: E501
 p: str = u1.name
index b1dabe8dc9b9a836e3eb20515571dedb61bc6082..e8ce35114e70d3542f18f4b97eb0c307564848f8 100644 (file)
@@ -19,5 +19,5 @@ class User:
 
 u1 = User()
 
-# EXPECTED_MYPY: Incompatible types in assignment (expression has type "Optional[str]", variable has type "Optional[int]") # noqa E501
+# EXPECTED_MYPY: Incompatible types in assignment (expression has type "Optional[str]", variable has type "Optional[int]") # noqa: E501
 p: Optional[int] = u1.name
index 2154ff074c6344c4431e122ffc36acc5b44bdd95..d72649b62a4c625f5f9783706441c3c08804fb9b 100644 (file)
@@ -22,5 +22,5 @@ class User:
 
 u1 = User()
 
-# EXPECTED_MYPY: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  # noqa E501
+# EXPECTED_MYPY: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  # noqa: E501
 p: str = u1.name
index 5084de7225e1154e782db3671fb037d7214f6ec6..e9ff303ca781618cecbf80cd22c5109dac658f45 100644 (file)
@@ -11,5 +11,5 @@ class User:
     __tablename__ = "user"
 
     id = Column(Integer(), primary_key=True)
-    # EXPECTED: Left hand assignment 'name: "int"' not compatible with ORM mapped expression # noqa E501
+    # EXPECTED: Left hand assignment 'name: "int"' not compatible with ORM mapped expression # noqa: E501
     name: int = Column(String())
index beb4a7a5d0cd51eae557f95f667d79918f3258af..0b933db4785ad8e75c80c4457e07912c76cefb11 100644 (file)
@@ -20,6 +20,6 @@ class Address:
     __tablename__ = "address"
 
     id = Column(Integer, primary_key=True)
-    # EXPECTED: Can't infer type from ORM mapped expression assigned to attribute 'user_id';  # noqa E501
+    # EXPECTED: Can't infer type from ORM mapped expression assigned to attribute 'user_id';  # noqa: E501
     user_id = Column(ForeignKey("user.id"))
     email_address = Column(String)
index 681c9d57bab6f997ef4e0f44af5c9a238525e0e7..5a6a29727323430646ed04e0b807c101f395ea5c 100644 (file)
@@ -174,7 +174,7 @@ class MypyPluginTest(fixtures.TestBase):
                 if m:
                     is_mypy = bool(m.group(1))
                     expected_msg = m.group(2)
-                    expected_msg = re.sub(r"# noqa ?.*", "", m.group(2))
+                    expected_msg = re.sub(r"# noqa[:]? ?.*", "", m.group(2))
                     expected_errors.append(
                         (num, is_mypy, expected_msg.strip())
                     )
index 253dfa17b1455550e796af2ea20a0f6e959745ed..33a91184c26a490ca8f7a677c6054afaa5a849c1 100644 (file)
@@ -3151,7 +3151,7 @@ class DeprecatedInhTest(_poly_fixtures._Polymorphic):
         mach_alias = machines.select()
 
         # note python 2 does not allow parens here; reformat in py3 only
-        with DeprecatedQueryTest._expect_implicit_subquery(), _aliased_join_warning(  # noqa E501
+        with DeprecatedQueryTest._expect_implicit_subquery(), _aliased_join_warning(  # noqa: E501
             "Person->people"
         ):
             self.assert_compile(
@@ -3884,7 +3884,7 @@ class NonPrimaryMapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
         with testing.expect_deprecated(
             "The mapper.non_primary parameter is deprecated"
         ):
-            m = self.mapper_registry.map_imperatively(  # noqa F841
+            m = self.mapper_registry.map_imperatively(  # noqa: F841
                 User,
                 users,
                 non_primary=True,
@@ -3947,7 +3947,7 @@ class NonPrimaryMapperTest(_fixtures.FixtureTest, AssertsCompiledSQL):
         with testing.expect_deprecated(
             "The mapper.non_primary parameter is deprecated"
         ):
-            m = mapper(  # noqa F841
+            m = mapper(  # noqa: F841
                 User,
                 users,
                 non_primary=True,
index c4326b8abc863ae97588140332c82f44a5af34c6..3a9a06728cbd078f1bf65a3d1e7954e7f0cd0507 100644 (file)
@@ -1399,7 +1399,7 @@ class TableValuedCompileTest(fixtures.TestBase, AssertsCompiledSQL):
         `WITH ORDINALITY AS unnested(unnested, ordinality) ON true
         LEFT OUTER JOIN b ON unnested.unnested = b.ref
 
-        """  # noqa 501
+        """  # noqa: 501
 
         a = table("a", column("id"), column("refs"))
         b = table("b", column("id"), column("ref"))