From a22d21a43c2eb7a12944377168727ed76a51aaa9 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Wed, 14 Feb 2024 20:35:24 +0100 Subject: [PATCH] Update black to 24.1.1 Change-Id: Iebd9b9e866a6a58541c187e70d4f170fdf84daff --- .pre-commit-config.yaml | 2 +- alembic/autogenerate/api.py | 6 +- alembic/autogenerate/render.py | 40 +++++++----- alembic/config.py | 15 ++--- alembic/ddl/_autogen.py | 26 ++++---- alembic/ddl/base.py | 9 +-- alembic/ddl/impl.py | 15 +++-- alembic/ddl/mysql.py | 80 ++++++++++++++--------- alembic/ddl/oracle.py | 8 ++- alembic/operations/base.py | 9 +-- alembic/operations/ops.py | 6 +- alembic/operations/schemaobj.py | 10 +-- alembic/runtime/environment.py | 12 ++-- alembic/runtime/migration.py | 18 ++--- alembic/script/base.py | 18 ++--- alembic/script/revision.py | 43 +++++++----- alembic/testing/fixtures.py | 22 ++++--- alembic/testing/suite/test_environment.py | 6 +- alembic/util/langhelpers.py | 9 +-- alembic/util/sqla_compat.py | 6 +- reap_dbs.py | 1 + setup.cfg | 2 +- tests/test_autogen_indexes.py | 9 +-- tests/test_autogen_render.py | 1 - tests/test_batch.py | 26 ++++---- tests/test_mssql.py | 7 +- tests/test_version_traversal.py | 2 - tox.ini | 4 +- 28 files changed, 226 insertions(+), 186 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1a8b418..ac4be898 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: 23.3.0 + rev: 24.1.1 hooks: - id: black diff --git a/alembic/autogenerate/api.py b/alembic/autogenerate/api.py index aa8f32f6..4c039162 100644 --- a/alembic/autogenerate/api.py +++ b/alembic/autogenerate/api.py @@ -596,9 +596,9 @@ def _run_environment( migration_script = self.generated_revisions[-1] if not getattr(migration_script, "_needs_render", False): migration_script.upgrade_ops_list[-1].upgrade_token = upgrade_token - migration_script.downgrade_ops_list[ - -1 - ].downgrade_token = downgrade_token + migration_script.downgrade_ops_list[-1].downgrade_token = ( + downgrade_token + ) migration_script._needs_render = True else: migration_script._upgrade_ops.append( diff --git a/alembic/autogenerate/render.py b/alembic/autogenerate/render.py index 317a6dbe..61d56acf 100644 --- a/alembic/autogenerate/render.py +++ b/alembic/autogenerate/render.py @@ -187,9 +187,11 @@ def _render_create_table_comment( prefix=_alembic_autogenerate_prefix(autogen_context), tname=op.table_name, comment="%r" % op.comment if op.comment is not None else None, - existing="%r" % op.existing_comment - if op.existing_comment is not None - else None, + existing=( + "%r" % op.existing_comment + if op.existing_comment is not None + else None + ), schema="'%s'" % op.schema if op.schema is not None else None, indent=" ", ) @@ -216,9 +218,11 @@ def _render_drop_table_comment( return templ.format( prefix=_alembic_autogenerate_prefix(autogen_context), tname=op.table_name, - existing="%r" % op.existing_comment - if op.existing_comment is not None - else None, + existing=( + "%r" % op.existing_comment + if op.existing_comment is not None + else None + ), schema="'%s'" % op.schema if op.schema is not None else None, indent=" ", ) @@ -328,9 +332,11 @@ def _add_index(autogen_context: AutogenContext, op: ops.CreateIndexOp) -> str: _get_index_rendered_expressions(index, autogen_context) ), "unique": index.unique or False, - "schema": (", schema=%r" % _ident(index.table.schema)) - if index.table.schema - else "", + "schema": ( + (", schema=%r" % _ident(index.table.schema)) + if index.table.schema + else "" + ), "kwargs": ", " + ", ".join(opts) if opts else "", } return text @@ -592,9 +598,11 @@ def _get_index_rendered_expressions( idx: Index, autogen_context: AutogenContext ) -> List[str]: return [ - repr(_ident(getattr(exp, "name", None))) - if isinstance(exp, sa_schema.Column) - else _render_potential_expr(exp, autogen_context, is_index=True) + ( + repr(_ident(getattr(exp, "name", None))) + if isinstance(exp, sa_schema.Column) + else _render_potential_expr(exp, autogen_context, is_index=True) + ) for exp in idx.expressions ] @@ -1075,9 +1083,11 @@ def _render_check_constraint( ) return "%(prefix)sCheckConstraint(%(sqltext)s%(opts)s)" % { "prefix": _sqlalchemy_autogenerate_prefix(autogen_context), - "opts": ", " + (", ".join("%s=%s" % (k, v) for k, v in opts)) - if opts - else "", + "opts": ( + ", " + (", ".join("%s=%s" % (k, v) for k, v in opts)) + if opts + else "" + ), "sqltext": _render_potential_expr( constraint.sqltext, autogen_context, wrap_in_text=False ), diff --git a/alembic/config.py b/alembic/config.py index 4b2263fd..2c52e7cd 100644 --- a/alembic/config.py +++ b/alembic/config.py @@ -221,8 +221,7 @@ def get_template_directory(self) -> str: @overload def get_section( self, name: str, default: None = ... - ) -> Optional[Dict[str, str]]: - ... + ) -> Optional[Dict[str, str]]: ... # "default" here could also be a TypeVar # _MT = TypeVar("_MT", bound=Mapping[str, str]), @@ -230,14 +229,12 @@ def get_section( @overload def get_section( self, name: str, default: Dict[str, str] - ) -> Dict[str, str]: - ... + ) -> Dict[str, str]: ... @overload def get_section( self, name: str, default: Mapping[str, str] - ) -> Union[Dict[str, str], Mapping[str, str]]: - ... + ) -> Union[Dict[str, str], Mapping[str, str]]: ... def get_section( self, name: str, default: Optional[Mapping[str, str]] = None @@ -313,14 +310,12 @@ def get_section_option( return default @overload - def get_main_option(self, name: str, default: str) -> str: - ... + def get_main_option(self, name: str, default: str) -> str: ... @overload def get_main_option( self, name: str, default: Optional[str] = None - ) -> Optional[str]: - ... + ) -> Optional[str]: ... def get_main_option( self, name: str, default: Optional[str] = None diff --git a/alembic/ddl/_autogen.py b/alembic/ddl/_autogen.py index e22153c4..74715b18 100644 --- a/alembic/ddl/_autogen.py +++ b/alembic/ddl/_autogen.py @@ -287,18 +287,22 @@ def __init__( self.target_table, tuple(self.target_columns), ) + ( - (None if onupdate.lower() == "no action" else onupdate.lower()) - if onupdate - else None, - (None if ondelete.lower() == "no action" else ondelete.lower()) - if ondelete - else None, + ( + (None if onupdate.lower() == "no action" else onupdate.lower()) + if onupdate + else None + ), + ( + (None if ondelete.lower() == "no action" else ondelete.lower()) + if ondelete + else None + ), # convert initially + deferrable into one three-state value - "initially_deferrable" - if initially and initially.lower() == "deferred" - else "deferrable" - if deferrable - else "not deferrable", + ( + "initially_deferrable" + if initially and initially.lower() == "deferred" + else "deferrable" if deferrable else "not deferrable" + ), ) @util.memoized_property diff --git a/alembic/ddl/base.py b/alembic/ddl/base.py index 7a85a5c1..690c1537 100644 --- a/alembic/ddl/base.py +++ b/alembic/ddl/base.py @@ -40,7 +40,6 @@ class AlterTable(DDLElement): - """Represent an ALTER TABLE statement. Only the string name and optional schema name of the table @@ -238,9 +237,11 @@ def visit_column_default( return "%s %s %s" % ( alter_table(compiler, element.table_name, element.schema), alter_column(compiler, element.column_name), - "SET DEFAULT %s" % format_server_default(compiler, element.default) - if element.default is not None - else "DROP DEFAULT", + ( + "SET DEFAULT %s" % format_server_default(compiler, element.default) + if element.default is not None + else "DROP DEFAULT" + ), ) diff --git a/alembic/ddl/impl.py b/alembic/ddl/impl.py index bf202a48..d2983923 100644 --- a/alembic/ddl/impl.py +++ b/alembic/ddl/impl.py @@ -77,7 +77,6 @@ def __init__( class DefaultImpl(metaclass=ImplMeta): - """Provide the entrypoint for major migration operations, including database-specific behavioral variances. @@ -425,13 +424,15 @@ def bulk_insert( self._exec( sqla_compat._insert_inline(table).values( **{ - k: sqla_compat._literal_bindparam( - k, v, type_=table.c[k].type - ) - if not isinstance( - v, sqla_compat._literal_bindparam + k: ( + sqla_compat._literal_bindparam( + k, v, type_=table.c[k].type + ) + if not isinstance( + v, sqla_compat._literal_bindparam + ) + else v ) - else v for k, v in row.items() } ) diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index f312173e..3482f672 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -94,21 +94,29 @@ def alter_column( # type:ignore[override] column_name, schema=schema, newname=name if name is not None else column_name, - nullable=nullable - if nullable is not None - else existing_nullable - if existing_nullable is not None - else True, + nullable=( + nullable + if nullable is not None + else ( + existing_nullable + if existing_nullable is not None + else True + ) + ), type_=type_ if type_ is not None else existing_type, - default=server_default - if server_default is not False - else existing_server_default, - autoincrement=autoincrement - if autoincrement is not None - else existing_autoincrement, - comment=comment - if comment is not False - else existing_comment, + default=( + server_default + if server_default is not False + else existing_server_default + ), + autoincrement=( + autoincrement + if autoincrement is not None + else existing_autoincrement + ), + comment=( + comment if comment is not False else existing_comment + ), ) ) elif ( @@ -123,21 +131,29 @@ def alter_column( # type:ignore[override] column_name, schema=schema, newname=name if name is not None else column_name, - nullable=nullable - if nullable is not None - else existing_nullable - if existing_nullable is not None - else True, + nullable=( + nullable + if nullable is not None + else ( + existing_nullable + if existing_nullable is not None + else True + ) + ), type_=type_ if type_ is not None else existing_type, - default=server_default - if server_default is not False - else existing_server_default, - autoincrement=autoincrement - if autoincrement is not None - else existing_autoincrement, - comment=comment - if comment is not False - else existing_comment, + default=( + server_default + if server_default is not False + else existing_server_default + ), + autoincrement=( + autoincrement + if autoincrement is not None + else existing_autoincrement + ), + comment=( + comment if comment is not False else existing_comment + ), ) ) elif server_default is not False: @@ -368,9 +384,11 @@ def _mysql_alter_default( return "%s ALTER COLUMN %s %s" % ( alter_table(compiler, element.table_name, element.schema), format_column_name(compiler, element.column_name), - "SET DEFAULT %s" % format_server_default(compiler, element.default) - if element.default is not None - else "DROP DEFAULT", + ( + "SET DEFAULT %s" % format_server_default(compiler, element.default) + if element.default is not None + else "DROP DEFAULT" + ), ) diff --git a/alembic/ddl/oracle.py b/alembic/ddl/oracle.py index 54011740..eac99124 100644 --- a/alembic/ddl/oracle.py +++ b/alembic/ddl/oracle.py @@ -141,9 +141,11 @@ def visit_column_default( return "%s %s %s" % ( alter_table(compiler, element.table_name, element.schema), alter_column(compiler, element.column_name), - "DEFAULT %s" % format_server_default(compiler, element.default) - if element.default is not None - else "DEFAULT NULL", + ( + "DEFAULT %s" % format_server_default(compiler, element.default) + if element.default is not None + else "DEFAULT NULL" + ), ) diff --git a/alembic/operations/base.py b/alembic/operations/base.py index bafe441a..bd1b170d 100644 --- a/alembic/operations/base.py +++ b/alembic/operations/base.py @@ -406,8 +406,7 @@ def get_context(self) -> MigrationContext: return self.migration_context @overload - def invoke(self, operation: CreateTableOp) -> Table: - ... + def invoke(self, operation: CreateTableOp) -> Table: ... @overload def invoke( @@ -427,12 +426,10 @@ def invoke( DropTableOp, ExecuteSQLOp, ], - ) -> None: - ... + ) -> None: ... @overload - def invoke(self, operation: MigrateOperation) -> Any: - ... + def invoke(self, operation: MigrateOperation) -> Any: ... def invoke(self, operation: MigrateOperation) -> Any: """Given a :class:`.MigrateOperation`, invoke it in terms of diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index 7b65191c..0282d571 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -1371,9 +1371,9 @@ def to_table( info=self.info.copy() if self.info else {}, prefixes=list(self.prefixes) if self.prefixes else [], schema=self.schema, - _constraints_included=self._reverse._constraints_included - if self._reverse - else False, + _constraints_included=( + self._reverse._constraints_included if self._reverse else False + ), **self.table_kw, ) return t diff --git a/alembic/operations/schemaobj.py b/alembic/operations/schemaobj.py index 32b26e9b..59c1002f 100644 --- a/alembic/operations/schemaobj.py +++ b/alembic/operations/schemaobj.py @@ -223,10 +223,12 @@ def table(self, name: str, *columns, **kw) -> Table: t = sa_schema.Table(name, m, *cols, **kw) constraints = [ - sqla_compat._copy(elem, target_table=t) - if getattr(elem, "parent", None) is not t - and getattr(elem, "parent", None) is not None - else elem + ( + sqla_compat._copy(elem, target_table=t) + if getattr(elem, "parent", None) is not t + and getattr(elem, "parent", None) is not None + else elem + ) for elem in columns if isinstance(elem, (Constraint, Index)) ] diff --git a/alembic/runtime/environment.py b/alembic/runtime/environment.py index d64b2adc..a30972ec 100644 --- a/alembic/runtime/environment.py +++ b/alembic/runtime/environment.py @@ -108,7 +108,6 @@ class EnvironmentContext(util.ModuleClsProxy): - """A configurational facade made available in an ``env.py`` script. The :class:`.EnvironmentContext` acts as a *facade* to the more @@ -342,18 +341,17 @@ def get_tag_argument(self) -> Optional[str]: return self.context_opts.get("tag", None) # type: ignore[no-any-return] # noqa: E501 @overload - def get_x_argument(self, as_dictionary: Literal[False]) -> List[str]: - ... + def get_x_argument(self, as_dictionary: Literal[False]) -> List[str]: ... @overload - def get_x_argument(self, as_dictionary: Literal[True]) -> Dict[str, str]: - ... + def get_x_argument( + self, as_dictionary: Literal[True] + ) -> Dict[str, str]: ... @overload def get_x_argument( self, as_dictionary: bool = ... - ) -> Union[List[str], Dict[str, str]]: - ... + ) -> Union[List[str], Dict[str, str]]: ... def get_x_argument( self, as_dictionary: bool = False diff --git a/alembic/runtime/migration.py b/alembic/runtime/migration.py index 95c69bc6..6cfe5e23 100644 --- a/alembic/runtime/migration.py +++ b/alembic/runtime/migration.py @@ -86,7 +86,6 @@ def __exit__(self, type_: Any, value: Any, traceback: Any) -> None: class MigrationContext: - """Represent the database state made available to a migration script. @@ -218,9 +217,11 @@ def __init__( log.info("Generating static SQL") log.info( "Will assume %s DDL.", - "transactional" - if self.impl.transactional_ddl - else "non-transactional", + ( + "transactional" + if self.impl.transactional_ddl + else "non-transactional" + ), ) @classmethod @@ -345,9 +346,9 @@ def upgrade(): # except that it will not know it's in "autocommit" and will # emit deprecation warnings when an autocommit action takes # place. - self.connection = ( - self.impl.connection - ) = base_connection.execution_options(isolation_level="AUTOCOMMIT") + self.connection = self.impl.connection = ( + base_connection.execution_options(isolation_level="AUTOCOMMIT") + ) # sqlalchemy future mode will "autobegin" in any case, so take # control of that "transaction" here @@ -1006,8 +1007,7 @@ class MigrationStep: if TYPE_CHECKING: @property - def doc(self) -> Optional[str]: - ... + def doc(self) -> Optional[str]: ... @property def name(self) -> str: diff --git a/alembic/script/base.py b/alembic/script/base.py index 5945ca59..66564781 100644 --- a/alembic/script/base.py +++ b/alembic/script/base.py @@ -56,7 +56,6 @@ class ScriptDirectory: - """Provides operations upon an Alembic script directory. This object is useful to get information as to current revisions, @@ -732,9 +731,11 @@ def generate_revision( if depends_on: with self._catch_revision_errors(): resolved_depends_on = [ - dep - if dep in rev.branch_labels # maintain branch labels - else rev.revision # resolve partial revision identifiers + ( + dep + if dep in rev.branch_labels # maintain branch labels + else rev.revision + ) # resolve partial revision identifiers for rev, dep in [ (not_none(self.revision_map.get_revision(dep)), dep) for dep in util.to_list(depends_on) @@ -808,7 +809,6 @@ def _rev_path( class Script(revision.Revision): - """Represent a single revision file in a ``versions/`` directory. The :class:`.Script` instance is returned by methods @@ -930,9 +930,11 @@ def _head_only( if head_indicators or tree_indicators: text += "%s%s%s" % ( " (head)" if self._is_real_head else "", - " (effective head)" - if self.is_head and not self._is_real_head - else "", + ( + " (effective head)" + if self.is_head and not self._is_real_head + else "" + ), " (current)" if self._db_current_indicator else "", ) if tree_indicators: diff --git a/alembic/script/revision.py b/alembic/script/revision.py index 77a802cd..c3108e98 100644 --- a/alembic/script/revision.py +++ b/alembic/script/revision.py @@ -56,8 +56,7 @@ def __call__( inclusive: bool, implicit_base: bool, assert_relative_length: bool, - ) -> Tuple[Set[Revision], Tuple[Optional[_RevisionOrBase], ...]]: - ... + ) -> Tuple[Set[Revision], Tuple[Optional[_RevisionOrBase], ...]]: ... class RevisionError(Exception): @@ -720,9 +719,11 @@ def _shares_lineage( resolved_target = target resolved_test_against_revs = [ - self._revision_for_ident(test_against_rev) - if not isinstance(test_against_rev, Revision) - else test_against_rev + ( + self._revision_for_ident(test_against_rev) + if not isinstance(test_against_rev, Revision) + else test_against_rev + ) for test_against_rev in util.to_tuple( test_against_revs, default=() ) @@ -1016,9 +1017,9 @@ def get_ancestors(rev_id: str) -> Set[str]: # each time but it was getting complicated current_heads[current_candidate_idx] = heads_to_add[0] current_heads.extend(heads_to_add[1:]) - ancestors_by_idx[ - current_candidate_idx - ] = get_ancestors(heads_to_add[0]) + ancestors_by_idx[current_candidate_idx] = ( + get_ancestors(heads_to_add[0]) + ) ancestors_by_idx.extend( get_ancestors(head) for head in heads_to_add[1:] ) @@ -1183,9 +1184,13 @@ def _parse_downgrade_target( branch_label = symbol # Walk down the tree to find downgrade target. rev = self._walk( - start=self.get_revision(symbol) - if branch_label is None - else self.get_revision("%s@%s" % (branch_label, symbol)), + start=( + self.get_revision(symbol) + if branch_label is None + else self.get_revision( + "%s@%s" % (branch_label, symbol) + ) + ), steps=rel_int, no_overwalk=assert_relative_length, ) @@ -1303,9 +1308,13 @@ def _parse_upgrade_target( ) return ( self._walk( - start=self.get_revision(symbol) - if branch_label is None - else self.get_revision("%s@%s" % (branch_label, symbol)), + start=( + self.get_revision(symbol) + if branch_label is None + else self.get_revision( + "%s@%s" % (branch_label, symbol) + ) + ), steps=relative, no_overwalk=assert_relative_length, ), @@ -1694,15 +1703,13 @@ def is_merge_point(self) -> bool: @overload -def tuple_rev_as_scalar(rev: None) -> None: - ... +def tuple_rev_as_scalar(rev: None) -> None: ... @overload def tuple_rev_as_scalar( rev: Union[Tuple[_T, ...], List[_T]] -) -> Union[_T, Tuple[_T, ...], List[_T]]: - ... +) -> Union[_T, Tuple[_T, ...], List[_T]]: ... def tuple_rev_as_scalar( diff --git a/alembic/testing/fixtures.py b/alembic/testing/fixtures.py index b6cea632..3b5ce596 100644 --- a/alembic/testing/fixtures.py +++ b/alembic/testing/fixtures.py @@ -274,9 +274,11 @@ def _run_alter_col(self, from_, to_, compare=None): "x", column.name, existing_type=column.type, - existing_server_default=column.server_default - if column.server_default is not None - else False, + existing_server_default=( + column.server_default + if column.server_default is not None + else False + ), existing_nullable=True if column.nullable else False, # existing_comment=column.comment, nullable=to_.get("nullable", None), @@ -304,9 +306,13 @@ def _run_alter_col(self, from_, to_, compare=None): new_col["type"], new_col.get("default", None), compare.get("type", old_col["type"]), - compare["server_default"].text - if "server_default" in compare - else column.server_default.arg.text - if column.server_default is not None - else None, + ( + compare["server_default"].text + if "server_default" in compare + else ( + column.server_default.arg.text + if column.server_default is not None + else None + ) + ), ) diff --git a/alembic/testing/suite/test_environment.py b/alembic/testing/suite/test_environment.py index 8c86859a..df2d9afb 100644 --- a/alembic/testing/suite/test_environment.py +++ b/alembic/testing/suite/test_environment.py @@ -24,9 +24,9 @@ def _fixture(self, opts): self.context = MigrationContext.configure( dialect=conn.dialect, opts=opts ) - self.context.output_buffer = ( - self.context.impl.output_buffer - ) = io.StringIO() + self.context.output_buffer = self.context.impl.output_buffer = ( + io.StringIO() + ) else: self.context = MigrationContext.configure( connection=conn, opts=opts diff --git a/alembic/util/langhelpers.py b/alembic/util/langhelpers.py index 4a5bf09a..80d88cbc 100644 --- a/alembic/util/langhelpers.py +++ b/alembic/util/langhelpers.py @@ -234,20 +234,17 @@ def rev_id() -> str: @overload -def to_tuple(x: Any, default: Tuple[Any, ...]) -> Tuple[Any, ...]: - ... +def to_tuple(x: Any, default: Tuple[Any, ...]) -> Tuple[Any, ...]: ... @overload -def to_tuple(x: None, default: Optional[_T] = ...) -> _T: - ... +def to_tuple(x: None, default: Optional[_T] = ...) -> _T: ... @overload def to_tuple( x: Any, default: Optional[Tuple[Any, ...]] = None -) -> Tuple[Any, ...]: - ... +) -> Tuple[Any, ...]: ... def to_tuple( diff --git a/alembic/util/sqla_compat.py b/alembic/util/sqla_compat.py index 8489c19f..30b9b4c4 100644 --- a/alembic/util/sqla_compat.py +++ b/alembic/util/sqla_compat.py @@ -59,8 +59,7 @@ class _CompilerProtocol(Protocol): - def __call__(self, element: Any, compiler: Any, **kw: Any) -> str: - ... + def __call__(self, element: Any, compiler: Any, **kw: Any) -> str: ... def _safe_int(value: str) -> Union[int, str]: @@ -95,8 +94,7 @@ class _Unsupported: def compiles( element: Type[ClauseElement], *dialects: str - ) -> Callable[[_CompilerProtocol], _CompilerProtocol]: - ... + ) -> Callable[[_CompilerProtocol], _CompilerProtocol]: ... else: from sqlalchemy.ext.compiler import compiles diff --git a/reap_dbs.py b/reap_dbs.py index ae7ff858..6b2215df 100644 --- a/reap_dbs.py +++ b/reap_dbs.py @@ -10,6 +10,7 @@ database in process. """ + import logging import sys diff --git a/setup.cfg b/setup.cfg index fa957eca..3c516430 100644 --- a/setup.cfg +++ b/setup.cfg @@ -86,7 +86,7 @@ enable-extensions = G ignore = A003, D, - E203,E305,E711,E712,E721,E722,E741, + E203,E305,E704,E711,E712,E721,E722,E741, N801,N802,N806, RST304,RST303,RST299,RST399, W503,W504 diff --git a/tests/test_autogen_indexes.py b/tests/test_autogen_indexes.py index b06e7c90..d1e95e96 100644 --- a/tests/test_autogen_indexes.py +++ b/tests/test_autogen_indexes.py @@ -642,9 +642,11 @@ def test_unnamed_cols_changed(self): diffs = { ( cmd, - isinstance(obj, (UniqueConstraint, Index)) - if obj.name is not None - else False, + ( + isinstance(obj, (UniqueConstraint, Index)) + if obj.name is not None + else False + ), ) for cmd, obj in diffs } @@ -1800,7 +1802,6 @@ def test_remove_plain_index_is_reported(self): class NoUqReportsIndAsUqTest(NoUqReflectionIndexTest): - """this test suite simulates the condition where: a. the dialect doesn't report unique constraints diff --git a/tests/test_autogen_render.py b/tests/test_autogen_render.py index eeeb92ed..254b6ddd 100644 --- a/tests/test_autogen_render.py +++ b/tests/test_autogen_render.py @@ -53,7 +53,6 @@ class AutogenRenderTest(TestBase): - """test individual directives""" def setUp(self): diff --git a/tests/test_batch.py b/tests/test_batch.py index 9992af2c..2806dde1 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -329,19 +329,21 @@ def _assert_impl( ) args["tname_colnames"] = ", ".join( - "CAST(%(schema)stname.%(name)s AS %(type)s) AS %(cast_label)s" - % { - "schema": args["schema"], - "name": name, - "type": impl.new_table.c[name].type, - "cast_label": name if sqla_14 else "anon_1", - } - if ( - impl.new_table.c[name].type._type_affinity - is not impl.table.c[name].type._type_affinity + ( + "CAST(%(schema)stname.%(name)s AS %(type)s) AS %(cast_label)s" + % { + "schema": args["schema"], + "name": name, + "type": impl.new_table.c[name].type, + "cast_label": name if sqla_14 else "anon_1", + } + if ( + impl.new_table.c[name].type._type_affinity + is not impl.table.c[name].type._type_affinity + ) + else "%(schema)stname.%(name)s" + % {"schema": args["schema"], "name": name} ) - else "%(schema)stname.%(name)s" - % {"schema": args["schema"], "name": name} for name in colnames if name in impl.table.c ) diff --git a/tests/test_mssql.py b/tests/test_mssql.py index 693ab57d..fccde264 100644 --- a/tests/test_mssql.py +++ b/tests/test_mssql.py @@ -1,4 +1,5 @@ """Test op functions against MSSQL.""" + from __future__ import annotations from typing import Any @@ -118,9 +119,9 @@ def test_alter_column_type_and_nullability( expected_nullability = not existing_nullability args["nullable"] = expected_nullability else: - args[ - "existing_nullable" - ] = expected_nullability = existing_nullability + args["existing_nullable"] = expected_nullability = ( + existing_nullability + ) op.alter_column("t", "c", **args) diff --git a/tests/test_version_traversal.py b/tests/test_version_traversal.py index 09816dff..2fd07a95 100644 --- a/tests/test_version_traversal.py +++ b/tests/test_version_traversal.py @@ -554,7 +554,6 @@ def test_downgrade_no_effect_branched(self): class BranchFromMergepointTest(MigrationTest): - """this is a form that will come up frequently in the "many independent roots with cross-dependencies" case. @@ -617,7 +616,6 @@ def test_mergepoint_to_only_one_side_downgrade(self): class BranchFrom3WayMergepointTest(MigrationTest): - """this is a form that will come up frequently in the "many independent roots with cross-dependencies" case. diff --git a/tox.ini b/tox.ini index 1c1d9428..a1265d81 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,7 @@ deps=pytest>4.6 backports.zoneinfo;python_version<"3.9" tzdata zimports - black==23.3.0 + black==24.1.1 greenlet>=1 @@ -97,7 +97,7 @@ deps= pydocstyle<4.0.0 # used by flake8-rst-docstrings pygments - black==23.3.0 + black==24.1.1 commands = flake8 ./alembic/ ./tests/ setup.py docs/build/conf.py {posargs} black --check setup.py tests alembic