Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class decorators changing class type cause wrong errors #3483

Closed
ojii opened this issue Jun 1, 2017 · 2 comments
Closed

class decorators changing class type cause wrong errors #3483

ojii opened this issue Jun 1, 2017 · 2 comments

Comments

@ojii
Copy link

ojii commented Jun 1, 2017

from typing import Type

class A:
    pass

def deco(cls) -> Type[A]:
    return A

@deco
class B:
    pass

def func(cls: Type[A]):
    assert cls is A

func(B)

Running mypy on that code causes this error:

hoge.py:16: error: Argument 1 to "func" has incompatible type "B"; expected Type[A]

mypy version is mypy 0.511-88e8ef28be2465d1693ace4d39cd422987a97220-dirty.

I would expect it to correctly detect the type of B.

@JelleZijlstra
Copy link
Member

This is a duplicate of #3135.

@ilevkivskyi
Copy link
Member

Yes, this is a duplicate of a more "broad" bug - mypy ignores class decorators altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants