Skip to content

Commit

Permalink
Fix constraint_name type in create_primary_key
Browse files Browse the repository at this point in the history
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: #1452
Pull-request-sha: 8afb2bf

Change-Id: Ic7bbbbfda85dafccdf44c73a6233140aa7e96a2d
  • Loading branch information
kasium authored and CaselIT committed Apr 4, 2024
1 parent 0bc8c63 commit 0171748
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion alembic/operations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion alembic/operations/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0171748

Please sign in to comment.