diff options
author | eykamp <chris@eykamp.com> | 2022-09-08 16:50:30 -0400 |
---|---|---|
committer | CaselIT <cfederico87@gmail.com> | 2022-09-11 22:36:24 +0200 |
commit | 747ec301529cf2a08d56d3596aedbf54a93b8742 (patch) | |
tree | aca4cb58c162f4296ee4f2d1fbf1b7c30187c5ee | |
parent | 5b081ce74a3af15ab9a4b36760bcaa6500918f0e (diff) | |
download | alembic-747ec301529cf2a08d56d3596aedbf54a93b8742.tar.gz |
Add missing types to **kw
Simple change to fix (some) type checking with Pyright and friends.
Add missing types to **kw
Simple update to types, consistent with other similar instances already in place.
<!-- 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: somewhere between the first and second options. I don't think it merits an issue or test coverage.
- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] 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: #1073
Pull-request: https://github.com/sqlalchemy/alembic/pull/1073
Pull-request-sha: 34f0e38e7193a65b659e8af7fff553427048f536
Change-Id: I5f84478e59a74d3d841ff32a0c536e5b32cc9b21
-rw-r--r-- | alembic/autogenerate/api.py | 3 | ||||
-rw-r--r-- | alembic/context.pyi | 5 | ||||
-rw-r--r-- | alembic/op.pyi | 16 | ||||
-rw-r--r-- | alembic/operations/ops.py | 50 | ||||
-rw-r--r-- | alembic/runtime/environment.py | 9 |
5 files changed, 43 insertions, 40 deletions
diff --git a/alembic/autogenerate/api.py b/alembic/autogenerate/api.py index 4ab8a35..5f1c7f3 100644 --- a/alembic/autogenerate/api.py +++ b/alembic/autogenerate/api.py @@ -430,7 +430,8 @@ class AutogenContext: @util.memoized_property def sorted_tables(self): - """Return an aggregate of the :attr:`.MetaData.sorted_tables` collection(s). + """Return an aggregate of the :attr:`.MetaData.sorted_tables` + collection(s). For a sequence of :class:`.MetaData` objects, this concatenates the :attr:`.MetaData.sorted_tables` collection diff --git a/alembic/context.pyi b/alembic/context.pyi index 5ec4703..14e1b5f 100644 --- a/alembic/context.pyi +++ b/alembic/context.pyi @@ -2,6 +2,7 @@ # ### imports are manually managed from __future__ import annotations +from typing import Any from typing import Callable from typing import ContextManager from typing import Optional @@ -94,7 +95,7 @@ def configure( sqlalchemy_module_prefix: str = "sa.", user_module_prefix: Optional[str] = None, on_version_apply: Optional[Callable] = None, - **kw, + **kw: Any, ) -> None: """Configure a :class:`.MigrationContext` within this :class:`.EnvironmentContext` which will provide database @@ -699,7 +700,7 @@ def is_transactional_ddl(): """ -def run_migrations(**kw) -> None: +def run_migrations(**kw: Any) -> None: """Run migrations as determined by the current command line configuration as well as versioning information present (or not) in the current diff --git a/alembic/op.pyi b/alembic/op.pyi index 3745684..59dfc58 100644 --- a/alembic/op.pyi +++ b/alembic/op.pyi @@ -105,7 +105,7 @@ def alter_column( existing_nullable: Optional[bool] = None, existing_comment: Optional[str] = None, schema: Optional[str] = None, - **kw + **kw: Any ) -> Optional[Table]: """Issue an "alter column" instruction using the current migration context. @@ -431,7 +431,7 @@ def create_check_constraint( table_name: str, condition: Union[str, BinaryExpression], schema: Optional[str] = None, - **kw + **kw: Any ) -> Optional[Table]: """Issue a "create check constraint" instruction using the current migration context. @@ -527,7 +527,7 @@ def create_foreign_key( match: Optional[str] = None, source_schema: Optional[str] = None, referent_schema: Optional[str] = None, - **dialect_kw + **dialect_kw: Any ) -> Optional[Table]: """Issue a "create foreign key" instruction using the current migration context. @@ -580,7 +580,7 @@ def create_index( columns: Sequence[Union[str, TextClause, Function]], schema: Optional[str] = None, unique: bool = False, - **kw + **kw: Any ) -> Optional[Table]: """Issue a "create index" instruction using the current migration context. @@ -667,7 +667,7 @@ def create_primary_key( """ -def create_table(table_name: str, *columns, **kw) -> Optional[Table]: +def create_table(table_name: str, *columns, **kw: Any) -> Optional[Table]: """Issue a "create table" instruction using the current migration context. @@ -776,7 +776,7 @@ def create_unique_constraint( table_name: str, columns: Sequence[str], schema: Optional[str] = None, - **kw + **kw: Any ) -> Any: """Issue a "create unique constraint" instruction using the current migration context. @@ -817,7 +817,7 @@ def create_unique_constraint( """ def drop_column( - table_name: str, column_name: str, schema: Optional[str] = None, **kw + table_name: str, column_name: str, schema: Optional[str] = None, **kw: Any ) -> Optional[Table]: """Issue a "drop column" instruction using the current migration context. @@ -879,7 +879,7 @@ def drop_index( index_name: str, table_name: Optional[str] = None, schema: Optional[str] = None, - **kw + **kw: Any ) -> Optional[Table]: """Issue a "drop index" instruction using the current migration context. diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index 176c6ba..997274d 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -260,7 +260,7 @@ class CreatePrimaryKeyOp(AddConstraintOp): table_name: str, columns: Sequence[str], schema: Optional[str] = None, - **kw, + **kw: Any, ) -> None: self.constraint_name = constraint_name self.table_name = table_name @@ -385,7 +385,7 @@ class CreateUniqueConstraintOp(AddConstraintOp): table_name: str, columns: Sequence[str], schema: Optional[str] = None, - **kw, + **kw: Any, ) -> None: self.constraint_name = constraint_name self.table_name = table_name @@ -436,7 +436,7 @@ class CreateUniqueConstraintOp(AddConstraintOp): table_name: str, columns: Sequence[str], schema: Optional[str] = None, - **kw, + **kw: Any, ) -> Any: """Issue a "create unique constraint" instruction using the current migration context. @@ -485,7 +485,7 @@ class CreateUniqueConstraintOp(AddConstraintOp): operations: "BatchOperations", constraint_name: str, columns: Sequence[str], - **kw, + **kw: Any, ) -> Any: """Issue a "create unique constraint" instruction using the current batch migration context. @@ -520,7 +520,7 @@ class CreateForeignKeyOp(AddConstraintOp): referent_table: str, local_cols: List[str], remote_cols: List[str], - **kw, + **kw: Any, ) -> None: self.constraint_name = constraint_name self.source_table = source_table @@ -602,7 +602,7 @@ class CreateForeignKeyOp(AddConstraintOp): match: Optional[str] = None, source_schema: Optional[str] = None, referent_schema: Optional[str] = None, - **dialect_kw, + **dialect_kw: Any, ) -> Optional["Table"]: """Issue a "create foreign key" instruction using the current migration context. @@ -680,7 +680,7 @@ class CreateForeignKeyOp(AddConstraintOp): deferrable: None = None, initially: None = None, match: None = None, - **dialect_kw, + **dialect_kw: Any, ) -> None: """Issue a "create foreign key" instruction using the current batch migration context. @@ -736,7 +736,7 @@ class CreateCheckConstraintOp(AddConstraintOp): table_name: str, condition: Union[str, "TextClause", "ColumnElement[Any]"], schema: Optional[str] = None, - **kw, + **kw: Any, ) -> None: self.constraint_name = constraint_name self.table_name = table_name @@ -780,7 +780,7 @@ class CreateCheckConstraintOp(AddConstraintOp): table_name: str, condition: Union[str, "BinaryExpression"], schema: Optional[str] = None, - **kw, + **kw: Any, ) -> Optional["Table"]: """Issue a "create check constraint" instruction using the current migration context. @@ -831,7 +831,7 @@ class CreateCheckConstraintOp(AddConstraintOp): operations: "BatchOperations", constraint_name: str, condition: "TextClause", - **kw, + **kw: Any, ) -> Optional["Table"]: """Issue a "create check constraint" instruction using the current batch migration context. @@ -866,7 +866,7 @@ class CreateIndexOp(MigrateOperation): columns: Sequence[Union[str, "TextClause", "ColumnElement[Any]"]], schema: Optional[str] = None, unique: bool = False, - **kw, + **kw: Any, ) -> None: self.index_name = index_name self.table_name = table_name @@ -917,7 +917,7 @@ class CreateIndexOp(MigrateOperation): columns: Sequence[Union[str, "TextClause", "Function"]], schema: Optional[str] = None, unique: bool = False, - **kw, + **kw: Any, ) -> Optional["Table"]: r"""Issue a "create index" instruction using the current migration context. @@ -971,7 +971,7 @@ class CreateIndexOp(MigrateOperation): operations: "BatchOperations", index_name: str, columns: List[str], - **kw, + **kw: Any, ) -> Optional["Table"]: """Issue a "create index" instruction using the current batch migration context. @@ -1003,7 +1003,7 @@ class DropIndexOp(MigrateOperation): table_name: Optional[str] = None, schema: Optional[str] = None, _reverse: Optional["CreateIndexOp"] = None, - **kw, + **kw: Any, ) -> None: self.index_name = index_name self.table_name = table_name @@ -1050,7 +1050,7 @@ class DropIndexOp(MigrateOperation): index_name: str, table_name: Optional[str] = None, schema: Optional[str] = None, - **kw, + **kw: Any, ) -> Optional["Table"]: r"""Issue a "drop index" instruction using the current migration context. @@ -1078,7 +1078,7 @@ class DropIndexOp(MigrateOperation): @classmethod def batch_drop_index( - cls, operations: BatchOperations, index_name: str, **kw + cls, operations: BatchOperations, index_name: str, **kw: Any ) -> Optional["Table"]: """Issue a "drop index" instruction using the current batch migration context. @@ -1109,7 +1109,7 @@ class CreateTableOp(MigrateOperation): schema: Optional[str] = None, _namespace_metadata: Optional["MetaData"] = None, _constraints_included: bool = False, - **kw, + **kw: Any, ) -> None: self.table_name = table_name self.columns = columns @@ -1172,7 +1172,7 @@ class CreateTableOp(MigrateOperation): @classmethod def create_table( - cls, operations: "Operations", table_name: str, *columns, **kw + cls, operations: "Operations", table_name: str, *columns, **kw: Any ) -> Optional["Table"]: r"""Issue a "create table" instruction using the current migration context. @@ -1607,7 +1607,7 @@ class AlterColumnOp(AlterTableOp): modify_server_default: Any = False, modify_name: Optional[str] = None, modify_type: Optional[Any] = None, - **kw, + **kw: Any, ) -> None: super(AlterColumnOp, self).__init__(table_name, schema=schema) self.column_name = column_name @@ -1770,7 +1770,7 @@ class AlterColumnOp(AlterTableOp): existing_nullable: Optional[bool] = None, existing_comment: Optional[str] = None, schema: Optional[str] = None, - **kw, + **kw: Any, ) -> Optional["Table"]: r"""Issue an "alter column" instruction using the current migration context. @@ -1897,7 +1897,7 @@ class AlterColumnOp(AlterTableOp): existing_comment: None = None, insert_before: None = None, insert_after: None = None, - **kw, + **kw: Any, ) -> Optional["Table"]: """Issue an "alter column" instruction using the current batch migration context. @@ -1954,7 +1954,7 @@ class AddColumnOp(AlterTableOp): table_name: str, column: "Column", schema: Optional[str] = None, - **kw, + **kw: Any, ) -> None: super(AddColumnOp, self).__init__(table_name, schema=schema) self.column = column @@ -2089,7 +2089,7 @@ class DropColumnOp(AlterTableOp): column_name: str, schema: Optional[str] = None, _reverse: Optional["AddColumnOp"] = None, - **kw, + **kw: Any, ) -> None: super(DropColumnOp, self).__init__(table_name, schema=schema) self.column_name = column_name @@ -2146,7 +2146,7 @@ class DropColumnOp(AlterTableOp): table_name: str, column_name: str, schema: Optional[str] = None, - **kw, + **kw: Any, ) -> Optional["Table"]: """Issue a "drop column" instruction using the current migration context. @@ -2190,7 +2190,7 @@ class DropColumnOp(AlterTableOp): @classmethod def batch_drop_column( - cls, operations: "BatchOperations", column_name: str, **kw + cls, operations: "BatchOperations", column_name: str, **kw: Any ) -> Optional["Table"]: """Issue a "drop column" instruction using the current batch migration context. diff --git a/alembic/runtime/environment.py b/alembic/runtime/environment.py index 5fcee57..b95e0b5 100644 --- a/alembic/runtime/environment.py +++ b/alembic/runtime/environment.py @@ -1,5 +1,6 @@ from __future__ import annotations +from typing import Any from typing import Callable from typing import ContextManager from typing import Dict @@ -106,7 +107,7 @@ class EnvironmentContext(util.ModuleClsProxy): """ def __init__( - self, config: "Config", script: "ScriptDirectory", **kw + self, config: "Config", script: "ScriptDirectory", **kw: Any ) -> None: r"""Construct a new :class:`.EnvironmentContext`. @@ -133,7 +134,7 @@ class EnvironmentContext(util.ModuleClsProxy): self._install_proxy() return self - def __exit__(self, *arg, **kw) -> None: + def __exit__(self, *arg: Any, **kw: Any) -> None: self._remove_proxy() def is_offline_mode(self) -> bool: @@ -347,7 +348,7 @@ class EnvironmentContext(util.ModuleClsProxy): sqlalchemy_module_prefix: str = "sa.", user_module_prefix: Optional[str] = None, on_version_apply: Optional[Callable] = None, - **kw, + **kw: Any, ) -> None: """Configure a :class:`.MigrationContext` within this :class:`.EnvironmentContext` which will provide database @@ -828,7 +829,7 @@ class EnvironmentContext(util.ModuleClsProxy): opts=opts, ) - def run_migrations(self, **kw) -> None: + def run_migrations(self, **kw: Any) -> None: """Run migrations as determined by the current command line configuration as well as versioning information present (or not) in the current |