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

import p.b when p's __init__.py is not in build silently produces any #4797

Open
msullivan opened this issue Mar 26, 2018 · 1 comment
Open
Labels
bug mypy got something wrong

Comments

@msullivan
Copy link
Collaborator

The following test fails, producing no output:

[case testInitNotInBuild1]
# cmd: mypy -m p.a p.b
# flags: --follow-imports=skip
[file p/__init__.py]
[file p/a.py]
import p.b
p.b.f('hi')  # E: Argument 1 to "f" has incompatible type "str"; expected "int"
[file p/b.py]
def f(x: int) -> None: pass

Adding a reveal_type(p.b) reveals that its type is Any.

The following two variants of this test, using from ... import ..., both pass, however:

[case testInitNotInBuild2]
# cmd: mypy -m p.a p.b
# flags: --follow-imports=skip
[file p/__init__.py]
[file p/a.py]
from p.b import f
f('hi')  # E: Argument 1 to "f" has incompatible type "str"; expected "int"
[file p/b.py]
def f(x: int) -> None: pass

[case testInitNotInBuild3]
# cmd: mypy -m p.a p.b
# flags: --follow-imports=skip
[file p/__init__.py]
[file p/a.py]
from p import b
b.f('hi')  # E: Argument 1 to "f" has incompatible type "str"; expected "int"
[file p/b.py]
def f(x: int) -> None: pass
@msullivan msullivan added the bug mypy got something wrong label Mar 26, 2018
@gvanrossum
Copy link
Member

gvanrossum commented Mar 26, 2018 via email

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

No branches or pull requests

2 participants