Skip to content

Commit f944b51

Browse files
zzzeekGerrit Code Review
authored andcommitted
Merge "Fix constraint_name type of create_foreign_key"
2 parents ed55fa8 + 4abcbcd commit f944b51

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

alembic/op.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def create_exclude_constraint(
508508
"""
509509

510510
def create_foreign_key(
511-
constraint_name: str,
511+
constraint_name: Optional[str],
512512
source_table: str,
513513
referent_table: str,
514514
local_cols: List[str],
@@ -541,9 +541,9 @@ def create_foreign_key(
541541
off normally. The :class:`~sqlalchemy.schema.AddConstraint`
542542
construct is ultimately used to generate the ALTER statement.
543543
544-
:param name: Name of the foreign key constraint. The name is necessary
545-
so that an ALTER statement can be emitted. For setups that
546-
use an automated naming scheme such as that described at
544+
:param constraint_name: Name of the foreign key constraint. The name
545+
is necessary so that an ALTER statement can be emitted. For setups
546+
that use an automated naming scheme such as that described at
547547
:ref:`sqla:constraint_naming_conventions`,
548548
``name`` here can be ``None``, as the event listener will
549549
apply the name to the constraint object when it is associated
@@ -618,7 +618,7 @@ def create_index(
618618
"""
619619

620620
def create_primary_key(
621-
constraint_name: str,
621+
constraint_name: Optional[str],
622622
table_name: str,
623623
columns: List[str],
624624
schema: Optional[str] = None,
@@ -643,9 +643,9 @@ def create_primary_key(
643643
off normally. The :class:`~sqlalchemy.schema.AddConstraint`
644644
construct is ultimately used to generate the ALTER statement.
645645
646-
:param name: Name of the primary key constraint. The name is necessary
647-
so that an ALTER statement can be emitted. For setups that
648-
use an automated naming scheme such as that described at
646+
:param constraint_name: Name of the primary key constraint. The name
647+
is necessary so that an ALTER statement can be emitted. For setups
648+
that use an automated naming scheme such as that described at
649649
:ref:`sqla:constraint_naming_conventions`
650650
``name`` here can be ``None``, as the event listener will
651651
apply the name to the constraint object when it is associated
@@ -1002,7 +1002,7 @@ def execute(
10021002
op.execute("INSERT INTO table (foo) VALUES ('\:colon_value')")
10031003
10041004
1005-
:param sql: Any legal SQLAlchemy expression, including:
1005+
:param sqltext: Any legal SQLAlchemy expression, including:
10061006
10071007
* a string
10081008
* a :func:`sqlalchemy.sql.expression.text` construct.

alembic/operations/ops.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def to_constraint(
296296
def create_primary_key(
297297
cls,
298298
operations: "Operations",
299-
constraint_name: str,
299+
constraint_name: Optional[str],
300300
table_name: str,
301301
columns: List[str],
302302
schema: Optional[str] = None,
@@ -321,9 +321,9 @@ def create_primary_key(
321321
off normally. The :class:`~sqlalchemy.schema.AddConstraint`
322322
construct is ultimately used to generate the ALTER statement.
323323
324-
:param name: Name of the primary key constraint. The name is necessary
325-
so that an ALTER statement can be emitted. For setups that
326-
use an automated naming scheme such as that described at
324+
:param constraint_name: Name of the primary key constraint. The name
325+
is necessary so that an ALTER statement can be emitted. For setups
326+
that use an automated naming scheme such as that described at
327327
:ref:`sqla:constraint_naming_conventions`
328328
``name`` here can be ``None``, as the event listener will
329329
apply the name to the constraint object when it is associated
@@ -588,7 +588,7 @@ def to_constraint(
588588
def create_foreign_key(
589589
cls,
590590
operations: "Operations",
591-
constraint_name: str,
591+
constraint_name: Optional[str],
592592
source_table: str,
593593
referent_table: str,
594594
local_cols: List[str],
@@ -621,9 +621,9 @@ def create_foreign_key(
621621
off normally. The :class:`~sqlalchemy.schema.AddConstraint`
622622
construct is ultimately used to generate the ALTER statement.
623623
624-
:param name: Name of the foreign key constraint. The name is necessary
625-
so that an ALTER statement can be emitted. For setups that
626-
use an automated naming scheme such as that described at
624+
:param constraint_name: Name of the foreign key constraint. The name
625+
is necessary so that an ALTER statement can be emitted. For setups
626+
that use an automated naming scheme such as that described at
627627
:ref:`sqla:constraint_naming_conventions`,
628628
``name`` here can be ``None``, as the event listener will
629629
apply the name to the constraint object when it is associated
@@ -2389,7 +2389,7 @@ def execute(
23892389
op.execute("INSERT INTO table (foo) VALUES ('\:colon_value')")
23902390
23912391
2392-
:param sql: Any legal SQLAlchemy expression, including:
2392+
:param sqltext: Any legal SQLAlchemy expression, including:
23932393
23942394
* a string
23952395
* a :func:`sqlalchemy.sql.expression.text` construct.

docs/build/unreleased/914.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. change::
2+
:tags: bug, mypy
3+
:tickets: 914
4+
5+
Fixed type annotations for the "constraint_name" argument of operations
6+
``create_primary_key()``, ``create_foreign_key()``. Pull request courtesy
7+
TilmanK.
8+

0 commit comments

Comments
 (0)