-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
match process_revision_directives typing to API
Improved typing in the :paramref:`.EnvironmentContext.configure.process_revision_directives` callable to better indicate that the passed-in type is :class:`.MigrationScript`, not the :class:`.MigrationOperation` base class, and added typing to the example at :ref:`cookbook_no_empty_migrations` to illustrate. Change-Id: Ibfb7a57a081818c290cf0964d12a72b85c2c1983 Fixes: #1325
- Loading branch information
Showing
6 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -900,14 +900,26 @@ hook in :meth:`.MigrationContext.configure` which removes the | |
single :class:`.MigrationScript` directive if it is empty of | ||
any operations:: | ||
|
||
# for typing purposes | ||
from alembic.environment import MigrationContext | ||
|
||
# this typing-only import requires alembic 1.12.1 or above | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
zzzeek
Author
Member
|
||
from alembic.operations import MigrationScript | ||
|
||
|
||
def run_migrations_online(): | ||
|
||
# ... | ||
|
||
def process_revision_directives(context, revision, directives): | ||
def process_revision_directives( | ||
context: MigrationContext, | ||
revision: tuple[str, str], | ||
directives: list[MigrationScript], | ||
): | ||
assert config.cmd_opts is not None | ||
if config.cmd_opts.autogenerate: | ||
script = directives[0] | ||
assert script.upgrade_ops is not None | ||
if script.upgrade_ops.is_empty(): | ||
directives[:] = [] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. change:: | ||
:tags: bug, typing | ||
:tickets: 1325 | ||
|
||
Improved typing in the | ||
:paramref:`.EnvironmentContext.configure.process_revision_directives` | ||
callable to better indicate that the passed-in type is | ||
:class:`.MigrationScript`, not the :class:`.MigrationOperation` base class, | ||
and added typing to the example at :ref:`cookbook_no_empty_migrations` to | ||
illustrate. |
Alembic 1.12.1 hasn't been released, right?