]> 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 09:56:07 +0000 (11:56 +0200)
Change-Id: I5a241a70efba68bcea9819ddce6aebc25703e68d

18 files changed:
.pre-commit-config.yaml
lib/sqlalchemy/dialects/mysql/dml.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/reflection.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/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_manytomany.py

index 3da7408a202c2cbbe93987ee6cb1bc3124dccec4..013b2f9e148f74d01dd60d9dd67beb48768f5d4d 100644 (file)
@@ -12,7 +12,7 @@ repos:
     -   id: zimports
 
 -   repo: https://github.com/pycqa/flake8
-    rev: 4.0.1
+    rev: 5.0.0
     hooks:
     -   id: flake8
         additional_dependencies:
@@ -25,7 +25,3 @@ repos:
           # in case it requires a version pin
           - pydocstyle
           - pygments
-
-
-
-
index b93116c389dcb2bef4e3a4d254a7658a4f6d548e..4ee40b90928e847d99b53ed8f440d2681fa7cf85 100644 (file)
@@ -60,7 +60,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 3ff815f706bad45b13d5778e5f09ee07b99e91bf..0204fbbbb859be99f910cd538ed6a9893f9adf2d 100644 (file)
@@ -1413,7 +1413,8 @@ class CursorResult(Result[_T]):
 
     @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.
 
@@ -1754,7 +1755,8 @@ class CursorResult(Result[_T]):
 
     @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 c3c5ff5a8664874cfbf0f5a93fb9a5544d9953e4..f744d53ad6bace1ef5f148bccde1ed3a997cab71 100644 (file)
@@ -881,7 +881,8 @@ class Inspector(inspection.Inspectable["Inspector"]):
         scope: ObjectScope = ObjectScope.DEFAULT,
         **kw: Any,
     ) -> Dict[TableKey, List[ReflectedColumn]]:
-        r"""Return information about columns in all objects in the given schema.
+        r"""Return information about columns in all objects in the given
+        schema.
 
         The objects can be filtered by passing the names to use to
         ``filter_names``.
index a4e373ec311e79b05a3d234b33dae6a78320e0b2..df5a8199cc8818a620bff98073ae21bd3bfd0a8c 100644 (file)
@@ -1893,7 +1893,8 @@ class TupleResult(FilterResult[_R], util.TypingOnly):
             ...
 
         def scalar(self) -> Any:
-            """Fetch the first column of the first row, and close the result set.
+            """Fetch the first column of the first row, and close the result
+            set.
 
             Returns None if there are no rows to fetch.
 
@@ -2219,7 +2220,8 @@ SelfChunkedIteratorResult = TypeVar(
 
 
 class ChunkedIteratorResult(IteratorResult[_TP]):
-    """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 06976dd4ba14012773dc50b3a3a13bcf365d825d..045b32ac5766062a08fb7aa60a25bc7aa7775ac9 100644 (file)
@@ -307,7 +307,8 @@ class ROMappingItemsView(ROMappingView, typing.ItemsView[str, Any]):
 
 
 class RowMapping(BaseRow, typing.Mapping[str, Any]):
-    """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 43f5fae819c480ee574911503bfd99a1d679ddf6..8f1c07fd8c89d39a9eea8b56ccdd979034cf1532 100644 (file)
@@ -442,8 +442,8 @@ class AsyncResult(AsyncCommon[Row[_TP]]):
         return await greenlet_spawn(FrozenResult, self)
 
     def merge(self, *others: AsyncResult[_TP]) -> MergedResult[_TP]:
-        """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
@@ -648,8 +648,8 @@ SelfAsyncMappingResult = TypeVar(
 
 
 class AsyncMappingResult(AsyncCommon[RowMapping]):
-    """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.
@@ -974,7 +974,8 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
             ...
 
         async def scalar(self) -> Any:
-            """Fetch the first column of the first row, and close the result set.
+            """Fetch the first column of the first row, and close the result
+            set.
 
             Returns None if there are no rows to fetch.
 
index 49fe5140f0ca4897ab5fac8a84eb707eb20c1be9..44a1768a89d2dc15cd8d9257f60930fcaf1f4435 100644 (file)
@@ -76,8 +76,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 7cc0aa9c9175395dc0f2aa4dfc05fd729cad7d53..680e499815a040cd1cd6ad05aca24d9afab24697 100644 (file)
@@ -1927,7 +1927,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -1948,7 +1949,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -1969,7 +1971,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -1989,7 +1992,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -2011,7 +2015,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -2047,7 +2052,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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,
@@ -2082,7 +2088,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -2114,7 +2121,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -2131,7 +2139,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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
@@ -2154,7 +2163,8 @@ class SessionEvents(event.Events[Session]):
 
     @_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 e99f3541886a611a68a43900841ab49db97eaaf0..76a16eb1c84f90a3148631ea72e9fc054fc9f743 100644 (file)
@@ -590,8 +590,8 @@ class UpdateBase(
 
     @property
     def entity_description(self) -> Dict[str, Any]:
-        """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 befd262ecf5de85dd542cfeb582d89f8d64e9350..77c93aed6c656c6e051ae66bf10c278f37e4c24d 100644 (file)
@@ -462,7 +462,8 @@ class FunctionElement(Executable, ColumnElement[_T], 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 ce561697b5118a0f7ca8494342907c9d9a85aeb4..a6047bec1770cb72345773e858a00a0a300d945d 100644 (file)
@@ -1807,8 +1807,8 @@ class TableValuedAlias(LateralFromClause, Alias):
         return tva
 
     def lateral(self, name: Optional[str] = None) -> LateralFromClause:
-        """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::
 
@@ -5280,10 +5280,9 @@ class Select(
         *,
         full: bool = False,
     ) -> SelfSelect:
-        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`.
 
@@ -6559,7 +6558,8 @@ class Exists(UnaryExpression[bool]):
         self: SelfExists,
         *fromclauses: Union[Literal[None, False], _FromClauseArgument],
     ) -> SelfExists:
-        """Apply correlation to the subquery noted by this :class:`_sql.Exists`.
+        """Apply correlation to the subquery noted by this
+        :class:`_sql.Exists`.
 
         .. seealso::
 
@@ -6576,7 +6576,8 @@ class Exists(UnaryExpression[bool]):
         self: SelfExists,
         *fromclauses: Union[Literal[None, False], _FromClauseArgument],
     ) -> SelfExists:
-        """Apply correlation to the subquery noted by this :class:`_sql.Exists`.
+        """Apply correlation to the subquery noted by this
+        :class:`_sql.Exists`.
 
         .. seealso::
 
index 6c1a99daae9191f9b90970868c25c32bf336475b..90320701ea6d64b42e23455a07600032a0385efc 100644 (file)
@@ -290,8 +290,8 @@ class TypeEngine(Visitable, Generic[_T]):
     ] = util.EMPTY_DICT
 
     def evaluates_none(self: SelfTypeEngine) -> SelfTypeEngine:
-        """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.::
 
@@ -1356,7 +1356,8 @@ class Emulated(TypeEngineMixin):
         impltype: Type[Union[TypeEngine[Any], TypeEngineMixin]],
         **kw: Any,
     ) -> TypeEngine[Any]:
-        """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.
@@ -1428,7 +1429,8 @@ class NativeForEmulated(TypeEngineMixin):
         **kw: Any,
     ) -> TypeEngine[Any]:
 
-        """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 55b10bdd50f3028ec99c6d4a039c5ad4941e7a77..874383394b48f0dbe214adeff621b1d10dd99795 100644 (file)
@@ -252,9 +252,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.open()
 
index 852058a5ee8584d3e81eab4293313d63ee25625a..2e3874549eb80e3d004cc4883d6071dace7757bd 100644 (file)
@@ -2179,8 +2179,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 014ded45da3550aaff212860484a6e3189928eec..779239015f949f20c8836f026bae50286e62d109 100644 (file)
@@ -2484,9 +2484,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 bf70868b6d1ac389e4f0f16e209246b00b6e2195..b3fa35a6fa9f360af40ce39ed36823289b5ca5a8 100644 (file)
@@ -414,7 +414,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 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,