]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fix constraint_name type in create_primary_key
authorkasium <15907922+kasium@users.noreply.github.com>
Thu, 4 Apr 2024 18:11:58 +0000 (14:11 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Thu, 4 Apr 2024 18:58:28 +0000 (20:58 +0200)
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
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

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: #<issue number>` 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: #<issue number>` 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
alembic/operations/ops.py
setup.cfg

index 649e7f2b0fdd7e9db72caf8bc67031002f2121a9..27dd3b9e5f43c422352e37b18bb67258baee2c0d 100644 (file)
@@ -1771,7 +1771,7 @@ class BatchOperations(AbstractOperations):
             ...
 
         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.
index 3a9c033c13392124785d396919eda4d2836b84e8..e6f1fb64211de9429dca0af8ef578ad05eb79b9b 100644 (file)
@@ -349,7 +349,7 @@ class CreatePrimaryKeyOp(AddConstraintOp):
     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
index 3c516430571b9d1a086ee8cf9323910ffee589b4..70daeaddcc324c3373734df4ebfd17d1c15ecce3 100644 (file)
--- 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,