]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Add missing types to **kw
authoreykamp <chris@eykamp.com>
Thu, 8 Sep 2022 20:50:30 +0000 (16:50 -0400)
committerCaselIT <cfederico87@gmail.com>
Sun, 11 Sep 2022 20:36:24 +0000 (22:36 +0200)
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

alembic/autogenerate/api.py
alembic/context.pyi
alembic/op.pyi
alembic/operations/ops.py
alembic/runtime/environment.py

index 4ab8a3593fa9a599e14211a85d042543dbf457ec..5f1c7f3554bec57bc4d4db6e438331617830f03b 100644 (file)
@@ -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
index 5ec4703733a7c405cc4bcc2d460933f88c373a14..14e1b5fbc345d02468302b328e2eee372b7cdd96 100644 (file)
@@ -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
index 3745684f7600867ac1e26655be52c6a3714ab219..59dfc58927ae2bf2f8a5f0d1cd12b06640d7b484 100644 (file)
@@ -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.
index 176c6ba6d181a7d5d728a145b7ba2eae6dc0d3a7..997274d7d38566b7f23679339defe29d97345bd0 100644 (file)
@@ -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.
index 5fcee573575edd76b70e41cbd8d3548fce09300b..b95e0b5e562d327d7af01042e7eea07382572d06 100644 (file)
@@ -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