Skip to content

attribute is incorrectly Any when ParamSpec decorated function is referenced in itself followed by an if statement with a class that has a method in it #16496

@DetachHead

Description

@DetachHead
from typing import ParamSpec, Callable

P = ParamSpec("P")

class Thing:
    value: int

def deco(fn: Callable[P, None]) ->  Callable[P, None]:
    raise Exception


@deco
def f() -> None:
    state: Thing
    f
    if state.value:

        class C:
            def f2(self) -> None: ...

    reveal_type(state.value)  # two outputs: `int` and `Any`

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions