basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

Ensure defs from `TYPE_CHECKING` also exist in the else branch

Open KotlinIsland opened this issue 1 year ago • 0 comments

if TYPE_CHECKING:
    a = 1  # no corresponding real definition
print(a)

Of course this doesn't facilitate all usages:

if TYPE_CHECKING:
    from _typedshed import SupportsAmongUs
a: SupportsAmongUs  # only used as type, so it's ok

But really, that usage should be handled better, like with a type import.

KotlinIsland avatar Mar 21 '24 01:03 KotlinIsland