From: Charly Laurent Date: Tue, 1 Apr 2025 18:21:00 +0000 (-0400) Subject: fix `server_default` type hint X-Git-Tag: rel_1_16_0~25 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=db12e1918556dd463847db9ffb3e761231df9b1d;p=thirdparty%2Fsqlalchemy%2Falembic.git fix `server_default` type hint ### Description The docstring of `alter_column` states: "Set to `None` to have the default removed". The type hint should accept None. ### 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. Fixes: #1639 Closes: #1641 Pull-request: https://github.com/sqlalchemy/alembic/pull/1641 Pull-request-sha: 6642187d254681712443039a95cc1f3110549654 Change-Id: Icb7246b47805d9b2c1ab70d4e26f3e09354fe190 --- diff --git a/alembic/op.pyi b/alembic/op.pyi index 13a5852f..14e6c39a 100644 --- a/alembic/op.pyi +++ b/alembic/op.pyi @@ -146,7 +146,9 @@ def alter_column( *, nullable: Optional[bool] = None, comment: Union[str, Literal[False], None] = False, - server_default: Union[str, bool, Identity, Computed, TextClause] = False, + server_default: Union[ + str, bool, Identity, Computed, TextClause, None + ] = False, new_column_name: Optional[str] = None, type_: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None, existing_type: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None, diff --git a/alembic/operations/base.py b/alembic/operations/base.py index 13993114..d7823a5b 100644 --- a/alembic/operations/base.py +++ b/alembic/operations/base.py @@ -706,7 +706,7 @@ class Operations(AbstractOperations): nullable: Optional[bool] = None, comment: Union[str, Literal[False], None] = False, server_default: Union[ - str, bool, Identity, Computed, TextClause + str, bool, Identity, Computed, TextClause, None ] = False, new_column_name: Optional[str] = None, type_: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None, diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index eebc2323..8c0bdf85 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -1841,7 +1841,7 @@ class AlterColumnOp(AlterTableOp): nullable: Optional[bool] = None, comment: Optional[Union[str, Literal[False]]] = False, server_default: Union[ - str, bool, Identity, Computed, TextClause + str, bool, Identity, Computed, TextClause, None ] = False, new_column_name: Optional[str] = None, type_: Optional[Union[TypeEngine[Any], Type[TypeEngine[Any]]]] = None,