Skip to content

Type alias for Annotated[some_type, non_type] not supported #9315

Closed
@sk-

Description

@sk-

The following code:

from typing_extensions import Annotated
class Positive:...
PositiveInt = Annotated[int, Positive()]

triggers the following error:

test.py:3: error: Invalid type alias: expression is not a valid type

Mypy version: mypy 0.782
Python version: Python 3.7.7 (default, May 10 2020, 19:54:23)
[Clang 11.0.3 (clang-1103.0.32.59)] on darwin
Mypy config:

[mypy]
disallow_subclassing_any = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_return_any = True
strict_equality = True
ignore_missing_imports = False
strict_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
check_untyped_defs = True
new_semantic_analyzer = True

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions