]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update black to 25.1.0 to align it with alembic
authorFederico Caselli <cfederico87@gmail.com>
Tue, 20 May 2025 20:15:06 +0000 (22:15 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Fri, 23 May 2025 20:44:00 +0000 (22:44 +0200)
Change-Id: I2ac332237f18bbc44155eadee35c64f62adc2867
(cherry picked from commit 76e49d06ceed2121023defe2ff727acea0f1a0e5)

36 files changed:
.pre-commit-config.yaml
examples/dogpile_caching/helloworld.py
examples/dynamic_dict/__init__.py
examples/nested_sets/__init__.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/strategies.py
lib/sqlalchemy/event/api.py
lib/sqlalchemy/ext/asyncio/base.py
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/mypy/names.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/decl_base.py
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/events.py
lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/state_changes.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/pool/base.py
lib/sqlalchemy/pool/impl.py
lib/sqlalchemy/schema.py
lib/sqlalchemy/sql/_typing.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/default_comparator.py
lib/sqlalchemy/sql/expression.py
lib/sqlalchemy/sql/naming.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/sql/util.py
lib/sqlalchemy/sql/visitors.py
lib/sqlalchemy/types.py
test/ext/test_horizontal_shard.py
test/ext/test_orderinglist.py
test/orm/inheritance/test_assorted_poly.py
test/typing/plain_files/orm/relationship.py
test/typing/plain_files/orm/trad_relationship_uselist.py
tox.ini

index 35e10ee29d20901eb5d298d4855bc11b763d7a3c..c7d225e1ae07f180573ae40a0b6a7fff135d3edd 100644 (file)
@@ -2,7 +2,7 @@
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
 -   repo: https://github.com/python/black
-    rev: 24.10.0
+    rev: 25.1.0
     hooks:
     -   id: black
 
@@ -12,7 +12,7 @@ repos:
     -   id: zimports
 
 -   repo: https://github.com/pycqa/flake8
-    rev: 6.1.0
+    rev: 7.2.0
     hooks:
     -   id: flake8
         additional_dependencies:
@@ -37,4 +37,4 @@ repos:
         types: [rst]
         exclude: README.*
         additional_dependencies:
-            - black==24.10.0
+            - black==25.1.0
index 01934c59fab943b26d72be034c7f0b2e08dea2bf..df1c2a318ef6e2eb7747e40ea44dd2a490688a69 100644 (file)
@@ -1,6 +1,4 @@
-"""Illustrate how to load some data, and cache the results.
-
-"""
+"""Illustrate how to load some data, and cache the results."""
 
 from sqlalchemy import select
 from .caching_query import FromCache
index ed31df062fb66bfcf12d95beab57dbd0d31ba47d..c1d52d3c4307084c85ceb6c95e912dd6571e7a0d 100644 (file)
@@ -1,4 +1,4 @@
-""" Illustrates how to place a dictionary-like facade on top of a
+"""Illustrates how to place a dictionary-like facade on top of a
 "dynamic" relation, so that dictionary operations (assuming simple
 string keys) can operate upon a large collection without loading the
 full collection at once.
index 5fdfbcedc08646437e80d786c81816ab533699c5..cacab411b9a982a204916ee1778409b4dfa80ae0 100644 (file)
@@ -1,4 +1,4 @@
-""" Illustrates a rudimentary way to implement the "nested sets"
+"""Illustrates a rudimentary way to implement the "nested sets"
 pattern for hierarchical data using the SQLAlchemy ORM.
 
 .. autosource::
index 4292ed6d100c19b3349416e9cca7aa8e88298d39..ad0e4b6243586a3a8aa410025a5763b8fe63ff3b 100644 (file)
@@ -4,9 +4,7 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
-"""Defines :class:`_engine.Connection` and :class:`_engine.Engine`.
-
-"""
+"""Defines :class:`_engine.Connection` and :class:`_engine.Engine`."""
 from __future__ import annotations
 
 import contextlib
index 5dd7bca9a49e9a8d77766633b79bbeb97917abea..b4b8077ba05752331186d8d35def7764e345b3a0 100644 (file)
@@ -5,10 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Deprecated mock engine strategy used by Alembic.
-
-
-"""
+"""Deprecated mock engine strategy used by Alembic."""
 
 from __future__ import annotations
 
index b6ec8f6d32bef28850b904c149b2cc795e3ea9a9..01dd4bdd1bfe40217f86b0113114642d7431677f 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Public API functions for the event system.
-
-"""
+"""Public API functions for the event system."""
 from __future__ import annotations
 
 from typing import Any
index ce2c439f1609670f4ac0b010c7be129b99b33db3..72a617f4e227784884609eb0b03e7e9657a6714f 100644 (file)
@@ -215,7 +215,7 @@ class GeneratorStartableContext(StartableContext[_T_co]):
 
 
 def asyncstartablecontext(
-    func: Callable[..., AsyncIterator[_T_co]]
+    func: Callable[..., AsyncIterator[_T_co]],
 ) -> Callable[..., GeneratorStartableContext[_T_co]]:
     """@asyncstartablecontext decorator.
 
index 65c019954c214e7c9a120d42d09e20f22b554662..d4ecbdac9861e95e55895e969a2ef1fd22f370bd 100644 (file)
@@ -1431,7 +1431,7 @@ def _get_sync_engine_or_connection(
 
 
 def _get_sync_engine_or_connection(
-    async_engine: Union[AsyncEngine, AsyncConnection]
+    async_engine: Union[AsyncEngine, AsyncConnection],
 ) -> Union[Engine, Connection]:
     if isinstance(async_engine, AsyncConnection):
         return async_engine._proxied
index 319786288fdb43ed7b70bfa48be84b18a6013556..1eaef7759531e5117dccf55533231eea4b0ccf2b 100644 (file)
@@ -297,7 +297,7 @@ def type_id_for_callee(callee: Expression) -> Optional[int]:
 
 
 def type_id_for_named_node(
-    node: Union[NameExpr, MemberExpr, SymbolNode]
+    node: Union[NameExpr, MemberExpr, SymbolNode],
 ) -> Optional[int]:
     type_id, fullnames = _lookup.get(node.name, (None, None))
 
index ae0ba1029d14577a1bc25818008ff5ae4d4198b2..b9f8d32be9646d1b35044b8886f43dcb6cfed72c 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Constants and rudimental functions used throughout the ORM.
-
-"""
+"""Constants and rudimental functions used throughout the ORM."""
 
 from __future__ import annotations
 
@@ -435,7 +433,7 @@ def _inspect_mapped_object(instance: _T) -> Optional[InstanceState[_T]]:
 
 
 def _class_to_mapper(
-    class_or_mapper: Union[Mapper[_T], Type[_T]]
+    class_or_mapper: Union[Mapper[_T], Type[_T]],
 ) -> Mapper[_T]:
     # can't get mypy to see an overload for this
     insp = inspection.inspect(class_or_mapper, False)
@@ -447,7 +445,7 @@ def _class_to_mapper(
 
 
 def _mapper_or_none(
-    entity: Union[Type[_T], _InternalEntityType[_T]]
+    entity: Union[Type[_T], _InternalEntityType[_T]],
 ) -> Optional[Mapper[_T]]:
     """Return the :class:`_orm.Mapper` for the given class or None if the
     class is not mapped.
index d5ed61de53f41334b42c3c6d144aec286f1b987e..30b05948a5142d2dc79551a74b9270129a34d1b2 100644 (file)
@@ -2525,7 +2525,7 @@ def _column_descriptions(
 
 
 def _legacy_filter_by_entity_zero(
-    query_or_augmented_select: Union[Query[Any], Select[Any]]
+    query_or_augmented_select: Union[Query[Any], Select[Any]],
 ) -> Optional[_InternalEntityType[Any]]:
     self = query_or_augmented_select
     if self._setup_joins:
@@ -2540,7 +2540,7 @@ def _legacy_filter_by_entity_zero(
 
 
 def _entity_from_pre_ent_zero(
-    query_or_augmented_select: Union[Query[Any], Select[Any]]
+    query_or_augmented_select: Union[Query[Any], Select[Any]],
 ) -> Optional[_InternalEntityType[Any]]:
     self = query_or_augmented_select
     if not self._raw_columns:
index 1176b504186f5f1ab66afb5aa488534106b3089e..f09f4369f1b85a2f90844d1905d9bd53afb5e613 100644 (file)
@@ -103,6 +103,7 @@ class MappedClassProtocol(Protocol[_O]):
 
 class _DeclMappedClassProtocol(MappedClassProtocol[_O], Protocol):
     "Internal more detailed version of ``MappedClassProtocol``."
+
     metadata: MetaData
     __tablename__: str
     __mapper_args__: _MapperKwArgs
index b055240a353f46c3a719a0b8964084999b9c27f0..a8cafdd0b7a6b5fea3bcfec197df80cf94b2591c 100644 (file)
@@ -7,9 +7,7 @@
 # mypy: ignore-errors
 
 
-"""Relationship dependencies.
-
-"""
+"""Relationship dependencies."""
 
 from __future__ import annotations
 
index f161760e6da04e3eefe2640c6b96cba2da9b2a2e..5af78fc6b76e90dbf4bc434c699255c035568e41 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""ORM event interfaces.
-
-"""
+"""ORM event interfaces."""
 from __future__ import annotations
 
 from typing import Any
@@ -1602,7 +1600,7 @@ class SessionEvents(event.Events[Session]):
     _dispatch_target = Session
 
     def _lifecycle_event(  # type: ignore [misc]
-        fn: Callable[[SessionEvents, Session, Any], None]
+        fn: Callable[[SessionEvents, Session, Any], None],
     ) -> Callable[[SessionEvents, Session, Any], None]:
         _sessionevents_lifecycle_event_names.add(fn.__name__)
         return fn
index 388e46098d656c4308956d7cf977e4b1f4e25dd0..bb03e53d2b13b9258fe553dba53148fe4b669b4b 100644 (file)
@@ -4,9 +4,7 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
-"""Path tracking utilities, representing mapper graph traversals.
-
-"""
+"""Path tracking utilities, representing mapper graph traversals."""
 
 from __future__ import annotations
 
index 10e417e85d19ea02f3df4fad73c84bb9a3cc7736..a79874e1c7a0341c21340fb6eb5e5fbb0cf2dbf2 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""State tracking utilities used by :class:`_orm.Session`.
-
-"""
+"""State tracking utilities used by :class:`_orm.Session`."""
 
 from __future__ import annotations
 
index d9eaa2b388e3ac58edfefade944d200e966737e3..8ac34e2943b9bcb274d4abdd3087ccdfc38de784 100644 (file)
@@ -8,7 +8,7 @@
 
 
 """sqlalchemy.orm.interfaces.LoaderStrategy
-   implementations, and related MapperOptions."""
+implementations, and related MapperOptions."""
 
 from __future__ import annotations
 
index fe78506df9e5726d75fb7b08a55bb8415cdcad9e..ed4d7c115ab657f8a83da40c04fcd321cee0151f 100644 (file)
@@ -6,9 +6,7 @@
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
 
-"""Base constructs for connection pools.
-
-"""
+"""Base constructs for connection pools."""
 
 from __future__ import annotations
 
index f2b951d8e8dd5102e5a68b2ca5c6f64a671f6d40..cc597e1e62e0a3256644bd7881fec1ee6254966d 100644 (file)
@@ -6,9 +6,7 @@
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
 
-"""Pool implementation classes.
-
-"""
+"""Pool implementation classes."""
 from __future__ import annotations
 
 import threading
index 16f7ec37b3c539aa6ef8a9760658f59f78874eea..56b90ec99e84b219423df539d031d3dd39c7f92f 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Compatibility namespace for sqlalchemy.sql.schema and related.
-
-"""
+"""Compatibility namespace for sqlalchemy.sql.schema and related."""
 
 from __future__ import annotations
 
index 8fe86f63748ce3f7e11be9f7ffaa60d4604e4206..8e3c66e553f77b58d34ad612b466435cc203aacd 100644 (file)
@@ -337,11 +337,11 @@ if TYPE_CHECKING:
     def is_selectable(t: Any) -> TypeGuard[Selectable]: ...
 
     def is_select_base(
-        t: Union[Executable, ReturnsRows]
+        t: Union[Executable, ReturnsRows],
     ) -> TypeGuard[SelectBase]: ...
 
     def is_select_statement(
-        t: Union[Executable, ReturnsRows]
+        t: Union[Executable, ReturnsRows],
     ) -> TypeGuard[Select[Any]]: ...
 
     def is_table(t: FromClause) -> TypeGuard[TableClause]: ...
index 102fddd9447dfb24a947c105fd0bf232e14186d3..e27296b5332707f53931feef17299dc64fc01ff9 100644 (file)
@@ -6,9 +6,7 @@
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 # mypy: allow-untyped-defs, allow-untyped-calls
 
-"""Foundational utilities common to many sql modules.
-
-"""
+"""Foundational utilities common to many sql modules."""
 
 
 from __future__ import annotations
@@ -2154,7 +2152,7 @@ class ColumnSet(util.OrderedSet["ColumnClause[Any]"]):
 
 
 def _entity_namespace(
-    entity: Union[_HasEntityNamespace, ExternallyTraversible]
+    entity: Union[_HasEntityNamespace, ExternallyTraversible],
 ) -> _EntityNamespace:
     """Return the nearest .entity_namespace for the given entity.
 
index 7fa5dafe9ce4875e58fe79fedfc34cc34e3157fe..62c1be452e13d0cf800a6d3111b00bba988cdc86 100644 (file)
@@ -5,8 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Default implementation of SQL comparison operations.
-"""
+"""Default implementation of SQL comparison operations."""
 
 from __future__ import annotations
 
index f8ac3a9ecad8064bd26f2200b6836cb726bc6044..dc7dee13b12821e29f3216f9e0721e96d8a078d5 100644 (file)
@@ -5,10 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Defines the public namespace for SQL expression constructs.
-
-
-"""
+"""Defines the public namespace for SQL expression constructs."""
 
 
 from __future__ import annotations
index 58203e4b9a1d59155c815f244a985f54bf9c954b..ce68acf15b9b1e56b327ba16f4aab6e1742db3fb 100644 (file)
@@ -6,10 +6,7 @@
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 # mypy: allow-untyped-defs, allow-untyped-calls
 
-"""Establish constraint and index naming conventions.
-
-
-"""
+"""Establish constraint and index naming conventions."""
 
 from __future__ import annotations
 
index df3118b6d5650aa902d35f9c412243b5b440aae3..1e08ece53578298ae043203ac1c3fd98afd966fa 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Base types API.
-
-"""
+"""Base types API."""
 
 from __future__ import annotations
 
index 06ca153288716d49d5cf359c8abdd65ba60ad00c..9fc4e65d9b48cf641172ae5426870e7f9de70118 100644 (file)
@@ -6,9 +6,7 @@
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 # mypy: allow-untyped-defs, allow-untyped-calls
 
-"""High level utilities which build upon other modules here.
-
-"""
+"""High level utilities which build upon other modules here."""
 from __future__ import annotations
 
 from collections import deque
index e758350adf8db69eaccf450f4374d27a4a9749bd..276428516769d1aea5035500f1e74373b376cd12 100644 (file)
@@ -5,10 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Visitor/traversal interface and library functions.
-
-
-"""
+"""Visitor/traversal interface and library functions."""
 
 from __future__ import annotations
 
index c2b1ab1945f463173901e2e3825fa4051ab373cf..bb2c2e11de36331a86232693111627a04b62e162 100644 (file)
@@ -5,9 +5,7 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
 
-"""Compatibility namespace for sqlalchemy.sql.types.
-
-"""
+"""Compatibility namespace for sqlalchemy.sql.types."""
 
 
 from __future__ import annotations
index 3ff49fc82fe98e22d4c982a08b7810ba0e6ebc44..4d579fa0c1df3cd81d0862164341fe4df5d8a8f5 100644 (file)
@@ -51,7 +51,7 @@ class ShardTest:
 
     @classmethod
     def define_tables(cls, metadata):
-        global db1, db2, db3, db4, weather_locations, weather_reports
+        global weather_locations
 
         cls.tables.ids = ids = Table(
             "ids", metadata, Column("nextid", Integer, nullable=False)
index 90c7f385789c3f3b617801c190fa51e8d2d0c2c0..98e2a8207f9cb9bb3a07fc7346045d164da4ce5c 100644 (file)
@@ -70,7 +70,7 @@ class OrderingListTest(fixtures.MappedTest):
         """Build a relationship situation using the given
         test_collection_class factory"""
 
-        global metadata, slides_table, bullets_table, Slide, Bullet
+        global slides_table, bullets_table, Slide, Bullet
 
         slides_table = Table(
             "test_Slides",
index ab06dbaea3d4dc07ce1ce8c1cdafa8faf30d2371..9100970d44040b1635e5c3c1f33fdd5f4a0f4510 100644 (file)
@@ -819,7 +819,7 @@ class RelationshipTest6(fixtures.MappedTest):
 
     @classmethod
     def define_tables(cls, metadata):
-        global people, managers, data
+        global people, managers
         people = Table(
             "people",
             metadata,
index 44090ad53b4ea5d7a6fba4a5be41a8751c9ee64a..a972e23b83e84994c049fe467b55fcd95ce58261 100644 (file)
@@ -1,6 +1,4 @@
-"""this suite experiments with other kinds of relationship syntaxes.
-
-"""
+"""this suite experiments with other kinds of relationship syntaxes."""
 
 from __future__ import annotations
 
index 9282181f01bd4dd1dfeb11e940552164cf2aa0db..e15fe709341904fe19aee819adca2b3c0a1bbdbb 100644 (file)
@@ -1,7 +1,4 @@
-"""traditional relationship patterns with explicit uselist.
-
-
-"""
+"""traditional relationship patterns with explicit uselist."""
 
 import typing
 from typing import cast
diff --git a/tox.ini b/tox.ini
index 200c6b6bf0ecc56f59af08d75d3d04e72be3820f..6b3e970902b838c684a2652b959726904a085fc8 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -239,7 +239,7 @@ extras=
      {[greenletextras]extras}
 
 deps=
-      flake8==6.1.0
+      flake8==7.2.0
       flake8-import-order
       flake8-builtins
       flake8-future-annotations>=0.0.5
@@ -251,7 +251,7 @@ deps=
       # in case it requires a version pin
       pydocstyle
       pygments
-      black==24.10.0
+      black==25.1.0
       slotscheck>=0.17.0
 
       # required by generate_tuple_map_overloads