Skip to content

Strange type inference with invalid return type #2594

@decorator-factory

Description

@decorator-factory
def aaa() -> callable:
    ...

bbb = aaa()

reveal_type(bbb)

This shows the type of bbb to be (__obj: object) -> bool. I think it should've been Unknown since callable isn't a valid type annotation.

This could happen if aaa and bbb are inside library code you don't have control over. It's tempting to use callable as a non-generic version of typing.Callable, so this is how I found this behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published version

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions