Skip to content

Autogenerate migration has minor typing issues with mypy #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
igorbga opened this issue May 26, 2023 · 2 comments
Closed

Autogenerate migration has minor typing issues with mypy #1253

igorbga opened this issue May 26, 2023 · 2 comments
Labels
bug Something isn't working pep 484 typing related issues

Comments

@igorbga
Copy link

igorbga commented May 26, 2023

Using SqlAlchemy 2.X and Alembic 1.11.1.

mypy is complaining about down_revision, branch_labels, and depends_on needing explicit type annotation.

I guess that for down_revision this is only an issue for the first migration because after that it will always be initialized and detected as str.

The fix seems trivial, but I'm not an Alembic expert at all so I might be missing something:

down_revision: Optional[str] = None
branch_labels: Optional[str] = None
depends_on: Optional[str] = None

Maybe this is intended and neccesary in order to keep backwards compatibility with Python 2.x ?

@igorbga igorbga added the requires triage New issue that requires categorization label May 26, 2023
@CaselIT CaselIT added bug Something isn't working pep 484 typing related issues and removed requires triage New issue that requires categorization labels May 26, 2023
@CaselIT
Copy link
Member

CaselIT commented May 26, 2023

Hi,

thanks for reporting.
This can be fixed in the alembic templates, but existing install will need to edit the script.py.mako file

@sqla-tester
Copy link
Collaborator

Federico Caselli has proposed a fix for this issue in the main branch:

Added typing to the default script mako templates. https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pep 484 typing related issues
Projects
None yet
Development

No branches or pull requests

3 participants