Skip to content
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

Missing typing support for string collections in some commands #930

Closed
QuicksilverMachine opened this issue Sep 23, 2021 · 2 comments
Closed
Labels
bug Something isn't working pep 484 typing related issues

Comments

@QuicksilverMachine
Copy link

Describe the bug

Typing of a couple of parameters is wrong. They are set to be str or Optional[str] only, when they can accept lists or tuples. Specifically it's the following functions:

alembic.command.revision - depends_on parameter
alembic.command.stamp - revisions parameter
alembic.command.merge - revisions parameter

Expected behavior

The typing should reflect the implementation.

To Reproduce
Simply run mypy with parameters being a tuple or list of strings.

Error

************.py: note: In function "merge":
************.py:165: error: Argument "revisions" to "merge" has incompatible type "List[str]"; expected "str"  [arg-type]
            config, revisions=revisions, message=message, branch_label=branch_label
                              ^
************.py: note: In function "revision":
************.py:262: error: Argument "depends_on" to "revision" has incompatible type "Tuple[str]"; expected "Optional[str]"  [arg-type]
            depends_on=depends_on,
                       ^
************.py: note: In function "stamp":
************.py:302: error: Argument "revision" to "stamp" has incompatible type "Tuple[str]"; expected "str"  [arg-type]

Versions.

  • OS: MacOs
  • Python: 3.9.7
  • Alembic: 1.7.3
  • SQLAlchemy: 1.4.25
  • Database: not relevant
  • DBAPI: not relevant

Additional context
None

Have a nice day!

@QuicksilverMachine QuicksilverMachine added the requires triage New issue that requires categorization label Sep 23, 2021
@CaselIT CaselIT added bug Something isn't working mypy pep 484 typing related issues and removed requires triage New issue that requires categorization mypy labels Sep 23, 2021
@CaselIT
Copy link
Member

CaselIT commented Sep 23, 2021

Thanks for reporing. PRs are welcome

@sqla-tester
Copy link
Collaborator

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

Improve typings https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4836

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