Skip to content

TYPE_CHECKING only imports should trigger errors on non-annotation usage #16587

@RonnyPfannschmidt

Description

@RonnyPfannschmidt

Bug Report

this should warn for all non-annotation usages of FunctionType

from typing import TYPE_CHECKING, cast

if TYPE_CHECKING:
    from types import FunctionType
    
def testit(func: FunctionType) -> None:
    assert isinstance(func, FunctionType)


def something() -> None:
    pass


testit(cast(FunctionType, something)

Expected Behavior

warn that FunctionType can only be used in annotations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions