Skip to content

Generic type incorrectly un-narrowed following TypeIs #19282

Description

@hauntsaninja
from typing_extensions import Any, TypeIs, reveal_type
class C[T]:
v: T
def is_int(v: object) -> TypeIs[C[int]]: ...
def f(c: C[Any]):
if is_int(c):
reveal_type(c)
reveal_type(c) # should be C[Any], but is C[int]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-narrowingConditional type narrowing / bindertopic-typeguard-typeisTypeGuard / TypeIs / PEP 647 / PEP 742

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions