Skip to content

Narrowed type is not reflected in nested scopes #40

@MarcoGorelli

Description

@MarcoGorelli
from typing import Callable

class Foo:
    _window_function: Callable[[str], int] | None

    def foo(self) -> None:
        if (window_function := self._window_function):
            def bar() -> None:
                print(window_function('foo'))
            bar()
$ pyrefly check g.py 
ERROR g.py:9:23-38: Expected a callable, got None [not-callable]

Spotted in Narwhals

Metadata

Metadata

Assignees

Labels

metascoping-control-flowissues related to scoping and control flowusabilityUsability & readiness issues identified with running Pyrefly on top OSS projects

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions