Skip to content

Method/attribute of same name of return type fail to typecheck #1897

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

Closed
tharvik opened this issue Jul 18, 2016 · 2 comments
Closed

Method/attribute of same name of return type fail to typecheck #1897

tharvik opened this issue Jul 18, 2016 · 2 comments

Comments

@tharvik
Copy link
Contributor

tharvik commented Jul 18, 2016

class A: pass

class B:
    def A(self) -> A: pass

B().A()

is a valid python code, but mypy

/tmp/asd.py: note: In function "A":
/tmp/asd.py:4: error: Invalid type "A"

It was found while typing datetime.datetime.tzinfo which return a tzinfo.

@tharvik
Copy link
Contributor Author

tharvik commented Jul 18, 2016

Also found it while simply using it as attribute

class A: pass

class B:
    A = ...  # type: A

B().A

gives

/tmp/asd.py:4: error: Invalid type "A"

@tharvik tharvik changed the title Method of same name of return type fail to typecheck Method/attribute of same name of return type fail to typecheck Jul 18, 2016
@tharvik
Copy link
Contributor Author

tharvik commented Jul 18, 2016

Damn, duplicate of #1775, sorry about that.

@tharvik tharvik closed this as completed Jul 18, 2016
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

1 participant