From 0171748e247978779c2eb5ab0907f3af0869456e Mon Sep 17 00:00:00 2001 From: kasium <15907922+kasium@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:11:58 -0400 Subject: [PATCH] Fix constraint_name type in create_primary_key The constraint name in create_primary_key should be optional, but for batch operations is is required according to the type annotations ### Description Changed the type annotation to `Optional[str]` ### Checklist This pull request is: - [ ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [X] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #` in the commit message - please include tests. **Have a nice day!** Closes: #1452 Pull-request: https://github.com/sqlalchemy/alembic/pull/1452 Pull-request-sha: 8afb2bf3fbddc1b04a9da7c5cc5553dea2c1c593 Change-Id: Ic7bbbbfda85dafccdf44c73a6233140aa7e96a2d --- alembic/operations/base.py | 2 +- alembic/operations/ops.py | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alembic/operations/base.py b/alembic/operations/base.py index 649e7f2b..27dd3b9e 100644 --- a/alembic/operations/base.py +++ b/alembic/operations/base.py @@ -1771,7 +1771,7 @@ def create_index( ... def create_primary_key( - self, constraint_name: str, columns: List[str] + self, constraint_name: Optional[str], columns: List[str] ) -> None: """Issue a "create primary key" instruction using the current batch migration context. diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index 3a9c033c..e6f1fb64 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -349,7 +349,7 @@ def create_primary_key( def batch_create_primary_key( cls, operations: BatchOperations, - constraint_name: str, + constraint_name: Optional[str], columns: List[str], ) -> None: """Issue a "create primary key" instruction using the diff --git a/setup.cfg b/setup.cfg index 3c516430..70daeadd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -84,7 +84,7 @@ where = tests enable-extensions = G # E203 is due to https://github.com/PyCQA/pycodestyle/issues/373 ignore = - A003, + A003,A005 D, E203,E305,E704,E711,E712,E721,E722,E741, N801,N802,N806,