Skip to content

A way to interact with mypy statically / assert type information  #249

@DetachHead

Description

@DetachHead

eg:

a = 1
if TYPE_CHECKING:
    assert_type(a, upper_bound=int, narrowed_type=Literal[1], mro=[int, object])
def assert_type(a: T, upper_bound: object, narrowed_type: object, mro: object):
    if not TYPE_CHECKING:
        raise RuntimeError("DONT CALL ME")
    a_type = get_type_info(a)
    assert a_type.bound == int
    assert a_type.narrowed_type == Literal[1]
    assert a_type.mro == [int, object]
    mypy_note("bitsus")

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions