]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fix typing of `revision` argument in "Don't Generate Empty Migrations with Autogenera...
authorJohn T. Wodder II <git@varonathe.org>
Fri, 27 Oct 2023 15:06:17 +0000 (11:06 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Fri, 27 Oct 2023 15:06:17 +0000 (11:06 -0400)
### Description

Type-annotations were added to the "Don't Generate Empty Migrations with Autogenerate" cookbook recipe in commit 3e48ed0.  Later, in commit 222e4ba, the type of the `revision` argument to `process_revision_directives()` was changed from `tuple[str, str]` to `str | Iterable[str | None] | Iterable[str]`, but the recipe was not updated.  This PR updates the recipe so that it will type-check.

### Checklist
This pull request is:

- [x] 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.

Closes: #1340
Pull-request: https://github.com/sqlalchemy/alembic/pull/1340
Pull-request-sha: 254b4cbe06befaa61a7e11fef5020766f129c7a5

Change-Id: I1697c1d8a3965dae8e696c9f33c179d9f20ef09c

docs/build/cookbook.rst

index cde139146ee65a711676fab02c7d6ce6fc2ab5fa..fd84db0a8bc3434161502761e791253089984bd7 100644 (file)
@@ -901,6 +901,7 @@ single :class:`.MigrationScript` directive if it is empty of
 any operations::
 
     # for typing purposes
+    from collections.abc import Iterable
     from alembic.environment import MigrationContext
 
     # this typing-only import requires alembic 1.12.1 or above
@@ -913,7 +914,7 @@ any operations::
 
         def process_revision_directives(
             context: MigrationContext,
-            revision: tuple[str, str],
+            revision: str | Iterable[str | None] | Iterable[str],
             directives: list[MigrationScript],
         ):
             assert config.cmd_opts is not None