Skip to content

cls (which is str) has revealed type of "Type[builtins.object]" #13704

Description

@nickeldan

In this example

deffunc(cls: type) ->typing.Any:
ifclsisstr:
reveal_type(cls)
returncls(5)

mypy states

note: Revealed type is "builtins.type"

Makes sense. However, if I change it to

deffunc(cls: type) ->typing.Any:
ifissubclass(cls, int):
passelifclsisstr:
reveal_type(cls)
returncls(5)

mypy states

note: Revealed type is "Type[builtins.object]"
error: Too many arguments for "object"

This is on Python 3.8.10 and mypy 0.910.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-narrowingConditional type narrowing / binder

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions