From: Federico Caselli Date: Tue, 20 May 2025 20:15:06 +0000 (+0200) Subject: update black to 25.1.0 to align it with alembic X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a85938fe76935e90d9e7ae0db580806c0a06c6a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git update black to 25.1.0 to align it with alembic Change-Id: I2ac332237f18bbc44155eadee35c64f62adc2867 --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 35e10ee29d..c7d225e1ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/examples/dogpile_caching/helloworld.py b/examples/dogpile_caching/helloworld.py index 01934c59fa..df1c2a318e 100644 --- a/examples/dogpile_caching/helloworld.py +++ b/examples/dogpile_caching/helloworld.py @@ -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 diff --git a/examples/dynamic_dict/__init__.py b/examples/dynamic_dict/__init__.py index ed31df062f..c1d52d3c43 100644 --- a/examples/dynamic_dict/__init__.py +++ b/examples/dynamic_dict/__init__.py @@ -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. diff --git a/examples/nested_sets/__init__.py b/examples/nested_sets/__init__.py index 5fdfbcedc0..cacab411b9 100644 --- a/examples/nested_sets/__init__.py +++ b/examples/nested_sets/__init__.py @@ -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:: diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 5e562bcb13..49da1083a8 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -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 diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py index 5dd7bca9a4..b4b8077ba0 100644 --- a/lib/sqlalchemy/engine/strategies.py +++ b/lib/sqlalchemy/engine/strategies.py @@ -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 diff --git a/lib/sqlalchemy/event/api.py b/lib/sqlalchemy/event/api.py index b6ec8f6d32..01dd4bdd1b 100644 --- a/lib/sqlalchemy/event/api.py +++ b/lib/sqlalchemy/event/api.py @@ -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 diff --git a/lib/sqlalchemy/ext/asyncio/base.py b/lib/sqlalchemy/ext/asyncio/base.py index ce2c439f16..72a617f4e2 100644 --- a/lib/sqlalchemy/ext/asyncio/base.py +++ b/lib/sqlalchemy/ext/asyncio/base.py @@ -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. diff --git a/lib/sqlalchemy/ext/asyncio/engine.py b/lib/sqlalchemy/ext/asyncio/engine.py index bf3cae6349..a339113210 100644 --- a/lib/sqlalchemy/ext/asyncio/engine.py +++ b/lib/sqlalchemy/ext/asyncio/engine.py @@ -1433,7 +1433,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 diff --git a/lib/sqlalchemy/orm/base.py b/lib/sqlalchemy/orm/base.py index aff2b23ae2..c53ba44345 100644 --- a/lib/sqlalchemy/orm/base.py +++ b/lib/sqlalchemy/orm/base.py @@ -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 @@ -438,7 +436,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) @@ -450,7 +448,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. diff --git a/lib/sqlalchemy/orm/decl_base.py b/lib/sqlalchemy/orm/decl_base.py index 55f5236ce3..d1b6e74b03 100644 --- a/lib/sqlalchemy/orm/decl_base.py +++ b/lib/sqlalchemy/orm/decl_base.py @@ -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 diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 288d74f1c8..15c3a34818 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -7,9 +7,7 @@ # mypy: ignore-errors -"""Relationship dependencies. - -""" +"""Relationship dependencies.""" from __future__ import annotations diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py index e478c9ed65..53429139d8 100644 --- a/lib/sqlalchemy/orm/events.py +++ b/lib/sqlalchemy/orm/events.py @@ -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 @@ -1574,7 +1572,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 diff --git a/lib/sqlalchemy/orm/path_registry.py b/lib/sqlalchemy/orm/path_registry.py index aa1363ad82..d9e0226863 100644 --- a/lib/sqlalchemy/orm/path_registry.py +++ b/lib/sqlalchemy/orm/path_registry.py @@ -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 diff --git a/lib/sqlalchemy/orm/state_changes.py b/lib/sqlalchemy/orm/state_changes.py index 10e417e85d..a79874e1c7 100644 --- a/lib/sqlalchemy/orm/state_changes.py +++ b/lib/sqlalchemy/orm/state_changes.py @@ -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 diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 2a22678870..8e67973e4b 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -8,7 +8,7 @@ """sqlalchemy.orm.interfaces.LoaderStrategy - implementations, and related MapperOptions.""" +implementations, and related MapperOptions.""" from __future__ import annotations diff --git a/lib/sqlalchemy/pool/base.py b/lib/sqlalchemy/pool/base.py index 7c051f12af..e25e000f01 100644 --- a/lib/sqlalchemy/pool/base.py +++ b/lib/sqlalchemy/pool/base.py @@ -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 diff --git a/lib/sqlalchemy/pool/impl.py b/lib/sqlalchemy/pool/impl.py index 1355ca8e1c..0bfcb6e7d3 100644 --- a/lib/sqlalchemy/pool/impl.py +++ b/lib/sqlalchemy/pool/impl.py @@ -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 diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 16f7ec37b3..56b90ec99e 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -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 diff --git a/lib/sqlalchemy/sql/_typing.py b/lib/sqlalchemy/sql/_typing.py index eb5d09ec2d..14769dde17 100644 --- a/lib/sqlalchemy/sql/_typing.py +++ b/lib/sqlalchemy/sql/_typing.py @@ -340,11 +340,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[Unpack[TupleAny]]]: ... def is_table(t: FromClause) -> TypeGuard[TableClause]: ... diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index e4279964a0..fe6cdf6a07 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -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 @@ -2368,7 +2366,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. diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index f8ac3a9eca..dc7dee13b1 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -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 diff --git a/lib/sqlalchemy/sql/naming.py b/lib/sqlalchemy/sql/naming.py index 58203e4b9a..ce68acf15b 100644 --- a/lib/sqlalchemy/sql/naming.py +++ b/lib/sqlalchemy/sql/naming.py @@ -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 diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 90c93bcef1..7582df72f9 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -6,9 +6,7 @@ # the MIT License: https://www.opensource.org/licenses/mit-license.php # mypy: allow-untyped-defs, allow-untyped-calls -"""SQL specific types. - -""" +"""SQL specific types.""" from __future__ import annotations import collections.abc as collections_abc diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index becd500d5d..890214e2e4 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -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 diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index a98b51c1de..7dda0a12b9 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -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 diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index 34ac84953b..a5cf585ba4 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -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 diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index e0a4e356b6..c803bc9d91 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -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 diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index 8215c44e5d..485fce795c 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -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) diff --git a/test/ext/test_orderinglist.py b/test/ext/test_orderinglist.py index 90c7f38578..98e2a8207f 100644 --- a/test/ext/test_orderinglist.py +++ b/test/ext/test_orderinglist.py @@ -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", diff --git a/test/orm/inheritance/test_assorted_poly.py b/test/orm/inheritance/test_assorted_poly.py index 2b15b74251..ea8be8d376 100644 --- a/test/orm/inheritance/test_assorted_poly.py +++ b/test/orm/inheritance/test_assorted_poly.py @@ -820,7 +820,7 @@ class RelationshipTest6(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): - global people, managers, data + global people, managers people = Table( "people", metadata, diff --git a/test/typing/plain_files/orm/relationship.py b/test/typing/plain_files/orm/relationship.py index 44090ad53b..a972e23b83 100644 --- a/test/typing/plain_files/orm/relationship.py +++ b/test/typing/plain_files/orm/relationship.py @@ -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 diff --git a/test/typing/plain_files/orm/trad_relationship_uselist.py b/test/typing/plain_files/orm/trad_relationship_uselist.py index 9282181f01..e15fe70934 100644 --- a/test/typing/plain_files/orm/trad_relationship_uselist.py +++ b/test/typing/plain_files/orm/trad_relationship_uselist.py @@ -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 cf0e9d2bd7..3012ec8748 100644 --- a/tox.ini +++ b/tox.ini @@ -235,7 +235,7 @@ extras= {[greenletextras]extras} deps= - flake8==6.1.0 + flake8==7.2.0 flake8-import-order flake8-builtins flake8-future-annotations>=0.0.5 @@ -247,7 +247,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