FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

cls (which is str) has revealed type of "Type[builtins.object]" · Issue #13704 · python/mypy · GitHub

Repository navigation

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

Closed

Description

In this example

def func(cls: type) -> typing.Any:
    if cls is str:
        reveal_type(cls)
        return cls(5)

mypy states

note: Revealed type is "builtins.type"

Makes sense. However, if I change it to

def func(cls: type) -> typing.Any:
    if issubclass(cls, int):
        pass
    elif cls is str:
        reveal_type(cls)
        return cls(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.

Activity

  1. AlexWaygood commented on Sep 22, 2022

    Member

    Mypy 0.910 is pretty old, but this reproduces on mypy 0.971 as well: https://mypy-play.net/?mypy=0.971&python=3.10&gist=06680dd02ef89d10ada867a731a1f618

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL