Skip to content

Support bare class names for in-based narrowing #937

@ndmitchell

Description

@ndmitchell

Describe the Bug

from typing import *

def f(x: type[object]):
    if x in (int, float):
        reveal_type(x) # reveals type[object] in Pyrefly, but `type[int] | type[float]` in Pyright

Sandbox Link

https://pyrefly.org/sandbox/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoBUAUEQCYCmwUwAFAB4Bcsi5A2mAEYBW5AxjAF0AlAyJRxmKnUwooNVDAA01ADZgAhjBFiJukOQBu5dSoD68BOXpCiQA&version=3.12

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions