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

mypy not catching needing to specify a forward declaration. #4764

Closed
asincero opened this issue Mar 20, 2018 · 2 comments
Closed

mypy not catching needing to specify a forward declaration. #4764

asincero opened this issue Mar 20, 2018 · 2 comments

Comments

@asincero
Copy link

Steps to reproduce

mypy doesn't detect the need for a forward declaration. For example:

class Foo:
    def bar(o: Foo) -> None:
        print('bar called')
        
o = Foo()
o.bar()

Current behavior

mypy doesn't detect anything wrong with the above code.

Expected behavior

mypy should flag the reference to "Foo" on line 2 as being undefined.

mypy --version output

mypy 0.570

@gvanrossum
Copy link
Member

True. Alternatively, in Python 3.7 you will be able to write from __future__ import annotations and then annotations will no longer be evaluated when encountered at runtime.

@ilevkivskyi
Copy link
Member

Duplicate of #948

@ilevkivskyi ilevkivskyi marked this as a duplicate of #948 Mar 20, 2018
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