`import p.b` when p's `__init__.py` is not in build silently produces any
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with the test cases testInitNotInBuild1, testInitNotInBuild2, and testInitNotInBuild3, using the p/init.py, p/a.py, and p/b.py fixtures. Run the mypy -m p.a p.b command with --follow-imports=skip and trace the differing import behavior. Done means testInitNotInBuild1 reports the incompatible str argument, like the two from-import variants.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 54
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python/mypy
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug topic-configuration topic-error-reporting
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100