Skip to content

Missing typing support for string collections in some commands #930

Description

@QuicksilverMachine

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpep 484typing related issues

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions