]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Update to flake8 5.
authorFederico Caselli <cfederico87@gmail.com>
Sun, 31 Jul 2022 09:56:07 +0000 (11:56 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Sun, 31 Jul 2022 10:07:01 +0000 (12:07 +0200)
Change-Id: I5a241a70efba68bcea9819ddce6aebc25703e68d
(cherry picked from commit f8c4dba4e9f130c18ce00597c036bc26ae7abf90)

20 files changed:
.pre-commit-config.yaml
lib/sqlalchemy/dialects/mysql/dml.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/engine/row.py
lib/sqlalchemy/ext/asyncio/result.py
lib/sqlalchemy/ext/mypy/util.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/events.py
lib/sqlalchemy/sql/dml.py
lib/sqlalchemy/sql/functions.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/testing/requirements.py
test/orm/inheritance/test_basic.py
test/orm/inheritance/test_relationship.py
test/orm/test_assorted_eager.py
test/orm/test_deprecations.py
test/orm/test_manytomany.py
test/requirements.py

index 94ac2c6876b57c9346bca6ef551b3d9bb50b5002..91b1273748676d0e383227755a37c25e377c4b70 100644 (file)
@@ -14,7 +14,7 @@ repos:
     -   id: zimports
 
 -   repo: https://github.com/pycqa/flake8
-    rev: 3.9.2
+    rev: 5.0.0
     hooks:
     -   id: flake8
         additional_dependencies:
@@ -26,7 +26,3 @@ repos:
           # in case it requires a version pin
           - pydocstyle
           - pygments
-
-
-
-
index 0b508fe49def51617a6e5e71a45a3546984654a0..0c8791a0d7b0c8abde9f9d3ba982e793b02c6f4e 100644 (file)
@@ -29,7 +29,8 @@ class Insert(StandardInsert):
 
     @property
     def inserted(self):
-        """Provide the "inserted" namespace for an ON DUPLICATE KEY UPDATE statement
+        """Provide the "inserted" namespace for an ON DUPLICATE KEY UPDATE
+        statement
 
         MySQL's ON DUPLICATE KEY UPDATE clause allows reference to the row
         that would be inserted, via a special function called ``VALUES()``.
index abe58e2fde1a98f9bbe42610801c1d7fa7a58496..774916d95df6c6cbaf6c47c6179fa2a208417b5d 100644 (file)
@@ -1371,7 +1371,8 @@ class BaseCursorResult(object):
 
     @property
     def inserted_primary_key_rows(self):
-        """Return the value of :attr:`_engine.CursorResult.inserted_primary_key`
+        """Return the value of
+        :attr:`_engine.CursorResult.inserted_primary_key`
         as a row contained within a list; some dialects may support a
         multiple row form as well.
 
@@ -1712,7 +1713,8 @@ class BaseCursorResult(object):
 
     @property
     def returns_rows(self):
-        """True if this :class:`_engine.CursorResult` returns zero or more rows.
+        """True if this :class:`_engine.CursorResult` returns zero or more
+        rows.
 
         I.e. if it is legal to call the methods
         :meth:`_engine.CursorResult.fetchone`,
index 912dccf4bf897efee0f6ae1a25c8ec3ffaf554ad..1fd4e1c92f2d88c59eeb7074c6bf5f9d5dda6023 100644 (file)
@@ -1768,7 +1768,8 @@ def null_result():
 
 
 class ChunkedIteratorResult(IteratorResult):
-    """An :class:`.IteratorResult` that works from an iterator-producing callable.
+    """An :class:`.IteratorResult` that works from an iterator-producing
+    callable.
 
     The given ``chunks`` argument is a function that is given a number of rows
     to return in each chunk, or ``None`` for all rows.  The function should
index e6c32977391d7ec10b8490537c18c7659c984de0..e80e8c6bec92f88d1ba2d7c66058e48ced68e9a9 100644 (file)
@@ -549,7 +549,8 @@ class ROMappingView(
 
 
 class RowMapping(BaseRow, collections_abc.Mapping):
-    """A ``Mapping`` that maps column names and objects to :class:`.Row` values.
+    """A ``Mapping`` that maps column names and objects to :class:`.Row`
+    values.
 
     The :class:`.RowMapping` is available from a :class:`.Row` via the
     :attr:`.Row._mapping` attribute, as well as from the iterable interface
index c69fe191bec01c73e77cb0b00e6c9f403c7494e0..a77b6a8c94387cc36e0fd96a34b84dc644cb8d9b 100644 (file)
@@ -323,8 +323,8 @@ class AsyncResult(AsyncCommon):
         return await greenlet_spawn(FrozenResult, self)
 
     def merge(self, *others):
-        """Merge this :class:`_asyncio.AsyncResult` with other compatible result
-        objects.
+        """Merge this :class:`_asyncio.AsyncResult` with other compatible
+        result objects.
 
         The object returned is an instance of :class:`_engine.MergedResult`,
         which will be composed of iterators from the given result
@@ -495,8 +495,8 @@ class AsyncScalarResult(AsyncCommon):
 
 
 class AsyncMappingResult(AsyncCommon):
-    """A wrapper for a :class:`_asyncio.AsyncResult` that returns dictionary values
-    rather than :class:`_engine.Row` values.
+    """A wrapper for a :class:`_asyncio.AsyncResult` that returns dictionary
+    values rather than :class:`_engine.Row` values.
 
     The :class:`_asyncio.AsyncMappingResult` object is acquired by calling the
     :meth:`_asyncio.AsyncResult.mappings` method.
index 4d55cb72833fe911de69f3fc78c00a728308fb47..16b365e1eee970121fbdc31f8934542d2d96eb2a 100644 (file)
@@ -64,8 +64,9 @@ class SQLAlchemyAttribute:
         }
 
     def expand_typevar_from_subtype(self, sub_type: TypeInfo) -> None:
-        """Expands type vars in the context of a subtype when an attribute is inherited
-        from a generic super type."""
+        """Expands type vars in the context of a subtype when an attribute is
+        inherited from a generic super type.
+        """
         if not isinstance(self.type, TypeVarType):
             return
 
index 2a1d3a2c3a2c6d2b6a9b9af76d0108d06045f2c1..efa20fb1cd109996bf6b6b7dcfd217b152a3aeeb 100644 (file)
@@ -376,7 +376,8 @@ else:
 
 
 class Mapped(QueryableAttribute, _Generic_T):
-    """Represent an ORM mapped :term:`descriptor` attribute for typing purposes.
+    """Represent an ORM mapped :term:`descriptor` attribute for typing
+    purposes.
 
     This class represents the complete descriptor interface for any class
     attribute that will have been :term:`instrumented` by the ORM
index 2bef6394d420a80685e3a893ac2a3f7581d18903..39659c72325d1ea54480ac8cccda2e09b8f54428 100644 (file)
@@ -1895,7 +1895,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def transient_to_pending(self, session, instance):
-        """Intercept the "transient to pending" transition for a specific object.
+        """Intercept the "transient to pending" transition for a specific
+        object.
 
         This event is a specialization of the
         :meth:`.SessionEvents.after_attach` event which is only invoked
@@ -1916,7 +1917,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def pending_to_transient(self, session, instance):
-        """Intercept the "pending to transient" transition for a specific object.
+        """Intercept the "pending to transient" transition for a specific
+        object.
 
         This less common transition occurs when an pending object that has
         not been flushed is evicted from the session; this can occur
@@ -1937,7 +1939,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def persistent_to_transient(self, session, instance):
-        """Intercept the "persistent to transient" transition for a specific object.
+        """Intercept the "persistent to transient" transition for a specific
+        object.
 
         This less common transition occurs when an pending object that has
         has been flushed is evicted from the session; this can occur
@@ -1957,7 +1960,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def pending_to_persistent(self, session, instance):
-        """Intercept the "pending to persistent"" transition for a specific object.
+        """Intercept the "pending to persistent"" transition for a specific
+        object.
 
         This event is invoked within the flush process, and is
         similar to scanning the :attr:`.Session.new` collection within
@@ -1979,7 +1983,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def detached_to_persistent(self, session, instance):
-        """Intercept the "detached to persistent" transition for a specific object.
+        """Intercept the "detached to persistent" transition for a specific
+        object.
 
         This event is a specialization of the
         :meth:`.SessionEvents.after_attach` event which is only invoked
@@ -2015,7 +2020,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def loaded_as_persistent(self, session, instance):
-        """Intercept the "loaded as persistent" transition for a specific object.
+        """Intercept the "loaded as persistent" transition for a specific
+        object.
 
         This event is invoked within the ORM loading process, and is invoked
         very similarly to the :meth:`.InstanceEvents.load` event.  However,
@@ -2050,7 +2056,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def persistent_to_deleted(self, session, instance):
-        """Intercept the "persistent to deleted" transition for a specific object.
+        """Intercept the "persistent to deleted" transition for a specific
+        object.
 
         This event is invoked when a persistent object's identity
         is deleted from the database within a flush, however the object
@@ -2082,7 +2089,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def deleted_to_persistent(self, session, instance):
-        """Intercept the "deleted to persistent" transition for a specific object.
+        """Intercept the "deleted to persistent" transition for a specific
+        object.
 
         This transition occurs only when an object that's been deleted
         successfully in a flush is restored due to a call to
@@ -2099,7 +2107,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def deleted_to_detached(self, session, instance):
-        """Intercept the "deleted to detached" transition for a specific object.
+        """Intercept the "deleted to detached" transition for a specific
+        object.
 
         This event is invoked when a deleted object is evicted
         from the session.   The typical case when this occurs is when
@@ -2122,7 +2131,8 @@ class SessionEvents(event.Events):
 
     @_lifecycle_event
     def persistent_to_detached(self, session, instance):
-        """Intercept the "persistent to detached" transition for a specific object.
+        """Intercept the "persistent to detached" transition for a specific
+        object.
 
         This event is invoked when a persistent object is evicted
         from the session.  There are many conditions that cause this
index 4a343147c9656a3c17c696a321e7624f5d26ecfe..07a4d7b2d585b34cb83839a57086793ce0ff385e 100644 (file)
@@ -511,8 +511,8 @@ class UpdateBase(
 
     @property
     def entity_description(self):
-        """Return a :term:`plugin-enabled` description of the table and/or entity
-        which this DML construct is operating against.
+        """Return a :term:`plugin-enabled` description of the table and/or
+        entity which this DML construct is operating against.
 
         This attribute is generally useful when using the ORM, as an
         extended structure which includes information about mapped
index 963108d7c4c98a7c9e979ebfa59ff121db55afe4..29f41223d352fa42f8d51b4120ae8fe6538670a7 100644 (file)
@@ -418,7 +418,8 @@ class FunctionElement(Executable, ColumnElement, FromClause, Generative):
         return FunctionFilter(self, *criterion)
 
     def as_comparison(self, left_index, right_index):
-        """Interpret this expression as a boolean comparison between two values.
+        """Interpret this expression as a boolean comparison between two
+        values.
 
         This method is used for an ORM use case described at
         :ref:`relationship_custom_operator_sql_function`.
index 829f26030c4ca9acbc1efcb611eeb408684e6998..8379e1ca7350d763245c7ddf330f47bd8c363410 100644 (file)
@@ -1834,8 +1834,8 @@ class TableValuedAlias(Alias):
         return tva
 
     def lateral(self, name=None):
-        """Return a new :class:`_sql.TableValuedAlias` with the lateral flag set,
-        so that it renders as LATERAL.
+        """Return a new :class:`_sql.TableValuedAlias` with the lateral flag
+        set, so that it renders as LATERAL.
 
         .. seealso::
 
@@ -5485,10 +5485,9 @@ class Select(
         )
 
     def outerjoin_from(self, from_, target, onclause=None, full=False):
-        r"""Create a SQL LEFT OUTER JOIN against this :class:`_expression.Select`
-        object's criterion
-        and apply generatively, returning the newly resulting
-        :class:`_expression.Select`.
+        r"""Create a SQL LEFT OUTER JOIN against this
+        :class:`_expression.Select` object's criterion and apply generatively,
+        returning the newly resulting :class:`_expression.Select`.
 
         Usage is the same as that of :meth:`_selectable.Select.join_from`.
 
@@ -6768,7 +6767,8 @@ class Exists(UnaryExpression):
         return Select._create_select_from_fromclause(self, [self], **kwargs)
 
     def correlate(self, *fromclause):
-        """Apply correlation to the subquery noted by this :class:`_sql.Exists`.
+        """Apply correlation to the subquery noted by this
+        :class:`_sql.Exists`.
 
         .. seealso::
 
@@ -6782,7 +6782,8 @@ class Exists(UnaryExpression):
         return e
 
     def correlate_except(self, *fromclause):
-        """Apply correlation to the subquery noted by this :class:`_sql.Exists`.
+        """Apply correlation to the subquery noted by this
+        :class:`_sql.Exists`.
 
         .. seealso::
 
index 172ce0d884ec9d0345051c58ebb59a0d704e33dd..29dc74971c847684d3bc33350c9e1dbb753f9756 100644 (file)
@@ -179,8 +179,8 @@ class TypeEngine(Traversible):
     """
 
     def evaluates_none(self):
-        """Return a copy of this type which has the :attr:`.should_evaluate_none`
-        flag set to True.
+        """Return a copy of this type which has the
+        :attr:`.should_evaluate_none` flag set to True.
 
         E.g.::
 
@@ -1105,7 +1105,8 @@ class Emulated(object):
     """
 
     def adapt_to_emulated(self, impltype, **kw):
-        """Given an impl class, adapt this type to the impl assuming "emulated".
+        """Given an impl class, adapt this type to the impl assuming
+        "emulated".
 
         The impl should also be an "emulated" version of this type,
         most likely the same class as this type itself.
@@ -1152,7 +1153,8 @@ class NativeForEmulated(object):
 
     @classmethod
     def adapt_emulated_to_native(cls, impl, **kw):
-        """Given an impl, adapt this type's class to the impl assuming "native".
+        """Given an impl, adapt this type's class to the impl assuming
+        "native".
 
         The impl will be an :class:`.Emulated` class but not a
         :class:`.NativeForEmulated`.
index b3f7ddb502e64b507613bb6430fdcfbea7b557ce..857d1fdef1e3e6a25a9f09d0f57fbb63d535b679 100644 (file)
@@ -228,9 +228,8 @@ class SuiteRequirements(Requirements):
 
     @property
     def standalone_binds(self):
-        """target database/driver supports bound parameters as column expressions
-        without being in the context of a typed column.
-
+        """target database/driver supports bound parameters as column
+        expressions without being in the context of a typed column.
         """
         return exclusions.closed()
 
index 600726ce38e0f8a12265746bb49d7a5fa9995ea9..6285a80a7f3a8b690acec8f318c92b83026ce2e6 100644 (file)
@@ -2062,8 +2062,8 @@ class VersioningTest(fixtures.MappedTest):
 
 
 class DistinctPKTest(fixtures.MappedTest):
-    """test the construction of mapper.primary_key when an inheriting relationship
-    joins on a column other than primary key column."""
+    """test the construction of mapper.primary_key when an inheriting
+    relationship joins on a column other than primary key column."""
 
     run_inserts = "once"
     run_deletes = None
index d12cb1999a0d0aeea52065a9ef1a82c2be46b762..0b1967f51916970bac282290f4af8c201237fa50 100644 (file)
@@ -2512,9 +2512,9 @@ class JoinedloadOverWPolyAliased(
 class JoinAcrossJoinedInhMultiPath(
     fixtures.DeclarativeMappedTest, testing.AssertsCompiledSQL
 ):
-    """test long join paths with a joined-inh in the middle, where we go multiple
-    times across the same joined-inh to the same target but with other classes
-    in the middle.    E.g. test [ticket:2908]
+    """test long join paths with a joined-inh in the middle, where we go
+    multiple times across the same joined-inh to the same target but with
+    other classes in the middle.  E.g. test [ticket:2908]
     """
 
     run_setup_mappers = "once"
index f6d10d8e6529d7e017962e4060a0b61b63309830..86921ff9fc4fa65ff5cbe6359d5b25c0d3c06259 100644 (file)
@@ -415,7 +415,8 @@ class EagerTest2(fixtures.MappedTest):
         ),
 
     def test_eager_terminate(self):
-        """Eager query generation does not include the same mapper's table twice.
+        """Eager query generation does not include the same mapper's table
+        twice.
 
         Or, that bi-directional eager loads don't include each other in eager
         query generation.
index 05bfdf26dab319757dbb1df4ef0017913c9b9df0..8febf3b3fcf83862df9ea2cf630bd6f9a266f2c5 100644 (file)
@@ -1883,8 +1883,8 @@ class FromSelfTest(QueryTest, AssertsCompiledSQL):
             )
 
     def test_from_self_resets_joinpaths(self):
-        """test a join from from_self() doesn't confuse joins inside the subquery
-        with the outside.
+        """test a join from from_self() doesn't confuse joins inside the
+        subquery with the outside.
         """
 
         Item, Keyword = self.classes.Item, self.classes.Keyword
index 1abf5551a5eb8296cb72b824f5d5347512323590..1155096a446a5df1c64d1674911f00e79354a2dc 100644 (file)
@@ -226,8 +226,9 @@ class M2MTest(fixtures.MappedTest):
         assert p2 in p1.parent_places
 
     def test_joinedload_on_double(self):
-        """test that a mapper can have two eager relationships to the same table, via
-        two different association tables.  aliases are required."""
+        """test that a mapper can have two eager relationships to the same
+        table, via two different association tables.  aliases are required.
+        """
 
         (
             place_input,
index e47099013ee0b6bf021336396ba3abb15e1aceeb..68e5f8bfe2661db8c63ac296703f9e0cc766a113 100644 (file)
@@ -198,9 +198,8 @@ class DefaultRequirements(SuiteRequirements):
 
     @property
     def standalone_binds(self):
-        """target database/driver supports bound parameters as column expressions
-        without being in the context of a typed column.
-
+        """target database/driver supports bound parameters as column
+        expressions without being in the context of a typed column.
         """
         return skip_if(["firebird", "mssql+mxodbc"], "not supported by driver")