Skip to content

Commit

Permalink
Update black
Browse files Browse the repository at this point in the history
Change-Id: I836b9a322819c07ec202fdcca4fd52818b994bff
  • Loading branch information
CaselIT committed Jun 8, 2023
1 parent 9705736 commit 79738c9
Show file tree
Hide file tree
Showing 42 changed files with 5 additions and 124 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/python/black
rev: 22.3.0
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/sqlalchemyorg/zimports
rev: v0.4.0
rev: v0.6.0
hooks:
- id: zimports
args:
- --keep-unused-type-checking

- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
2 changes: 0 additions & 2 deletions alembic/autogenerate/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def __init__(
opts: Optional[dict] = None,
autogenerate: bool = True,
) -> None:

if (
autogenerate
and migration_context is not None
Expand Down Expand Up @@ -431,7 +430,6 @@ def run_name_filters(
parent_names["schema_qualified_table_name"] = table_name

for fn in self._name_filters:

if not fn(name, type_, parent_names):
return False
else:
Expand Down
15 changes: 0 additions & 15 deletions alembic/autogenerate/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def _populate_migration_script(
def _produce_net_changes(
autogen_context: AutogenContext, upgrade_ops: UpgradeOps
) -> None:

connection = autogen_context.connection
assert connection is not None
include_schemas = autogen_context.opts.get("include_schemas", False)
Expand Down Expand Up @@ -145,7 +144,6 @@ def _compare_tables(
upgrade_ops: UpgradeOps,
autogen_context: AutogenContext,
) -> None:

default_schema = inspector.bind.dialect.default_schema_name

# tables coming from the connection will not have "schema"
Expand Down Expand Up @@ -214,7 +212,6 @@ def _compare_tables(
)
sqla_compat._reflect_table(inspector, t)
if autogen_context.run_object_filters(t, tname, "table", True, None):

modify_table_ops = ops.ModifyTableOps(tname, [], schema=s)

comparators.dispatch("table")(
Expand Down Expand Up @@ -255,7 +252,6 @@ def _compare_tables(
if autogen_context.run_object_filters(
metadata_table, tname, "table", False, conn_table
):

modify_table_ops = ops.ModifyTableOps(tname, [], schema=s)
with _compare_columns(
s,
Expand All @@ -266,7 +262,6 @@ def _compare_tables(
autogen_context,
inspector,
):

comparators.dispatch("table")(
autogen_context,
modify_table_ops,
Expand Down Expand Up @@ -534,7 +529,6 @@ def _compare_indexes_and_uniques(
conn_table: Optional[Table],
metadata_table: Optional[Table],
) -> None:

inspector = autogen_context.inspector
is_create_table = conn_table is None
is_drop_table = metadata_table is None
Expand Down Expand Up @@ -913,7 +907,6 @@ def _correct_for_uq_duplicates_uix(
_uq_constraint_sig(uqs_dupe_indexes[overlap]).sig
not in unnamed_metadata_uqs
):

conn_unique_constraints.discard(uqs_dupe_indexes[overlap])
elif overlap not in metadata_ix_names:
conn_indexes.discard(conn_ix_names[overlap])
Expand All @@ -929,7 +922,6 @@ def _compare_nullable(
conn_col: Column[Any],
metadata_col: Column[Any],
) -> None:

metadata_col_nullable = metadata_col.nullable
conn_col_nullable = conn_col.nullable
alter_column_op.existing_nullable = conn_col_nullable
Expand Down Expand Up @@ -971,7 +963,6 @@ def _setup_autoincrement(
conn_col: Column[Any],
metadata_col: Column[Any],
) -> None:

if metadata_col.table._autoincrement_column is metadata_col:
alter_column_op.kw["autoincrement"] = True
elif metadata_col.autoincrement is True:
Expand All @@ -990,7 +981,6 @@ def _compare_type(
conn_col: Column[Any],
metadata_col: Column[Any],
) -> None:

conn_type = conn_col.type
alter_column_op.existing_type = conn_type
metadata_type = metadata_col.type
Expand Down Expand Up @@ -1027,7 +1017,6 @@ def _compare_type(
def _render_server_default_for_compare(
metadata_default: Optional[Any], autogen_context: AutogenContext
) -> Optional[str]:

if isinstance(metadata_default, sa_schema.DefaultClause):
if isinstance(metadata_default.arg, str):
metadata_default = metadata_default.arg
Expand Down Expand Up @@ -1129,7 +1118,6 @@ def _compare_server_default(
conn_col: Column[Any],
metadata_col: Column[Any],
) -> Optional[bool]:

metadata_default = metadata_col.server_default
conn_col_default = conn_col.server_default
if conn_col_default is None and metadata_default is None:
Expand Down Expand Up @@ -1218,7 +1206,6 @@ def _compare_column_comment(
conn_col: Column[Any],
metadata_col: Column[Any],
) -> Optional[Literal[False]]:

assert autogen_context.dialect is not None
if not autogen_context.dialect.supports_comments:
return None
Expand Down Expand Up @@ -1246,7 +1233,6 @@ def _compare_foreign_keys(
conn_table: Optional[Table],
metadata_table: Optional[Table],
) -> None:

# if we're doing CREATE TABLE, all FKs are created
# inline within the table def
if conn_table is None or metadata_table is None:
Expand Down Expand Up @@ -1366,7 +1352,6 @@ def _compare_table_comment(
conn_table: Optional[Table],
metadata_table: Optional[Table],
) -> None:

assert autogen_context.dialect is not None
if not autogen_context.dialect.supports_comments:
return
Expand Down
11 changes: 0 additions & 11 deletions alembic/autogenerate/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def _render_cmd_body(
op_container: ops.OpContainer,
autogen_context: AutogenContext,
) -> str:

buf = StringIO()
printer = PythonPrinter(buf)

Expand Down Expand Up @@ -165,7 +164,6 @@ def _render_modify_table(
def _render_create_table_comment(
autogen_context: AutogenContext, op: ops.CreateTableCommentOp
) -> str:

templ = (
"{prefix}create_table_comment(\n"
"{indent}'{tname}',\n"
Expand All @@ -190,7 +188,6 @@ def _render_create_table_comment(
def _render_drop_table_comment(
autogen_context: AutogenContext, op: ops.DropTableCommentOp
) -> str:

templ = (
"{prefix}drop_table_comment(\n"
"{indent}'{tname}',\n"
Expand Down Expand Up @@ -362,7 +359,6 @@ def _add_unique_constraint(
def _add_fk_constraint(
autogen_context: AutogenContext, op: ops.CreateForeignKeyOp
) -> str:

args = [repr(_render_gen_name(autogen_context, op.constraint_name))]
if not autogen_context._has_batch:
args.append(repr(_ident(op.source_table)))
Expand Down Expand Up @@ -411,7 +407,6 @@ def _add_check_constraint(constraint, autogen_context):
def _drop_constraint(
autogen_context: AutogenContext, op: ops.DropConstraintOp
) -> str:

if autogen_context._has_batch:
template = "%(prefix)sdrop_constraint" "(%(name)r, type_=%(type)r)"
else:
Expand All @@ -432,7 +427,6 @@ def _drop_constraint(

@renderers.dispatch_for(ops.AddColumnOp)
def _add_column(autogen_context: AutogenContext, op: ops.AddColumnOp) -> str:

schema, tname, column = op.schema, op.table_name, op.column
if autogen_context._has_batch:
template = "%(prefix)sadd_column(%(column)s)"
Expand All @@ -452,7 +446,6 @@ def _add_column(autogen_context: AutogenContext, op: ops.AddColumnOp) -> str:

@renderers.dispatch_for(ops.DropColumnOp)
def _drop_column(autogen_context: AutogenContext, op: ops.DropColumnOp) -> str:

schema, tname, column_name = op.schema, op.table_name, op.column_name

if autogen_context._has_batch:
Expand All @@ -476,7 +469,6 @@ def _drop_column(autogen_context: AutogenContext, op: ops.DropColumnOp) -> str:
def _alter_column(
autogen_context: AutogenContext, op: ops.AlterColumnOp
) -> str:

tname = op.table_name
cname = op.column_name
server_default = op.modify_server_default
Expand Down Expand Up @@ -566,7 +558,6 @@ def _render_potential_expr(
is_server_default: bool = False,
) -> str:
if isinstance(value, sql.ClauseElement):

if wrap_in_text:
template = "%(prefix)stext(%(sql)r)"
else:
Expand Down Expand Up @@ -675,7 +666,6 @@ def _render_column(
opts: List[Tuple[str, Any]] = []

if column.server_default:

rendered = _render_server_default( # type:ignore[assignment]
column.server_default, autogen_context
)
Expand Down Expand Up @@ -984,7 +974,6 @@ def _fk_colspec(
def _populate_render_fk_opts(
constraint: ForeignKeyConstraint, opts: List[Tuple[str, str]]
) -> None:

if constraint.onupdate:
opts.append(("onupdate", repr(constraint.onupdate)))
if constraint.ondelete:
Expand Down
1 change: 0 additions & 1 deletion alembic/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ def _display_history(config, script, base, head, currents=()):
for sc in script.walk_revisions(
base=base or "base", head=head or "heads"
):

if indicate_current:
sc._db_current_indicator = sc.revision in currents

Expand Down
2 changes: 0 additions & 2 deletions alembic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class Config:

r"""Represent an Alembic configuration.
Within an ``env.py`` script, this is available
Expand Down Expand Up @@ -563,7 +562,6 @@ def add_options(fn, parser, positional, kwargs):
and fn.__name__[0] != "_"
and fn.__module__ == "alembic.command"
):

spec = compat.inspect_getfullargspec(fn)
if spec[3] is not None:
positional = spec[0][1 : -len(spec[3])]
Expand Down
1 change: 0 additions & 1 deletion alembic/ddl/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ def render_type(
return False

def _compare_identity_default(self, metadata_identity, inspector_identity):

# ignored contains the attributes that were not considered
# because assumed to their default values in the db.
diff, ignored = _compare_identity_options(
Expand Down
3 changes: 0 additions & 3 deletions alembic/ddl/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def alter_column( # type:ignore[override]
existing_nullable: Optional[bool] = None,
**kw: Any,
) -> None:

if nullable is not None:
if type_ is not None:
# the NULL/NOT NULL alter will handle
Expand Down Expand Up @@ -231,9 +230,7 @@ def compare_server_default(
rendered_metadata_default,
rendered_inspector_default,
):

if rendered_metadata_default is not None:

rendered_metadata_default = re.sub(
r"[\(\) \"\']", "", rendered_metadata_default
)
Expand Down
1 change: 0 additions & 1 deletion alembic/ddl/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def correct_for_autogen_constraints(
metadata_unique_constraints,
metadata_indexes,
):

# TODO: if SQLA 1.0, make use of "duplicates_index"
# metadata
removed = set()
Expand Down
4 changes: 0 additions & 4 deletions alembic/ddl/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def create_index(self, index):
self._exec(CreateIndex(index))

def prep_table_for_batch(self, batch_impl, table):

for constraint in table.constraints:
if (
constraint.name is not None
Expand Down Expand Up @@ -157,7 +156,6 @@ def alter_column( # type:ignore[override]
existing_autoincrement: Optional[bool] = None,
**kw: Any,
) -> None:

using = kw.pop("postgresql_using", None)

if using is not None and type_ is None:
Expand Down Expand Up @@ -239,7 +237,6 @@ def correct_for_autogen_constraints(
metadata_unique_constraints,
metadata_indexes,
):

doubled_constraints = {
index
for index in conn_indexes
Expand Down Expand Up @@ -638,7 +635,6 @@ def _render_inline_exclude_constraint(


def _postgresql_autogenerate_prefix(autogen_context: AutogenContext) -> str:

imports = autogen_context.imports
if imports is not None:
imports.add("from sqlalchemy.dialects import postgresql")
Expand Down
2 changes: 0 additions & 2 deletions alembic/ddl/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def compare_server_default(
rendered_metadata_default: Optional[str],
rendered_inspector_default: Optional[str],
) -> bool:

if rendered_metadata_default is not None:
rendered_metadata_default = re.sub(
r"^\((.+)\)$", r"\1", rendered_metadata_default
Expand Down Expand Up @@ -193,7 +192,6 @@ def correct_for_autogen_constraints(
metadata_unique_constraints,
metadata_indexes,
):

self._skip_functional_indexes(metadata_indexes, conn_indexes)


Expand Down
1 change: 0 additions & 1 deletion alembic/operations/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ def _transfer_elements_to_new_table(self) -> None:
for const in (
list(self.named_constraints.values()) + self.unnamed_constraints
):

const_columns = {c.key for c in _columns_for_constraint(const)}

if not const_columns.issubset(self.column_transfers):
Expand Down
4 changes: 0 additions & 4 deletions alembic/operations/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def from_constraint(cls, constraint: Constraint) -> DropConstraintOp:
)

def to_constraint(self) -> Constraint:

if self._reverse is not None:
constraint = self._reverse.to_constraint()
constraint.name = self.constraint_name
Expand Down Expand Up @@ -397,7 +396,6 @@ def __init__(
def from_constraint(
cls, constraint: Constraint
) -> CreateUniqueConstraintOp:

constraint_table = sqla_compat._table_for_constraint(constraint)

uq_constraint = cast("UniqueConstraint", constraint)
Expand Down Expand Up @@ -535,7 +533,6 @@ def to_diff_tuple(self) -> Tuple[str, ForeignKeyConstraint]:

@classmethod
def from_constraint(cls, constraint: Constraint) -> CreateForeignKeyOp:

fk_constraint = cast("ForeignKeyConstraint", constraint)
kw: dict = {}
if fk_constraint.onupdate:
Expand Down Expand Up @@ -1758,7 +1755,6 @@ def has_changes(self) -> bool:
return False

def reverse(self) -> AlterColumnOp:

kw = self.kw.copy()
kw["existing_type"] = self.existing_type
kw["existing_nullable"] = self.existing_nullable
Expand Down
Loading

0 comments on commit 79738c9

Please sign in to comment.