You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When no .mypy_cache folder exists and a user runs mypy --install-types --non-interactive ./, mypy may fail on fundamental issues but suggest that the failure was because of "no mypy cache directory," confusing the user.
To Reproduce
I've created a minimum reproducible example. Please find it here.
I summarize the example below.
Expected Behavior
For the source tree
.
├── a
│ └── lib.py
├── b
│ └── lib.py
└── main.py
where all files are empty except main.py, which might contain
deff(i: int=0):
i="test"# This is a mypy violation.print(i)
if__name__=="__main__":
f()
we expect running mypy --install-types --non-interactive ./ at the root of the source tree to either (1) generate the .mypy_cache and then report any typing errors or (2) explain why it cannot generate the cache.
Actual Behavior
mypy fails because b.lib duplicates a.lib by name in the same module. However, mypy does not report the duplicate module error. Instead, it only reports error: --install-types failed (no mypy cache directory).
This behavior is particularly confusing in CI, where our environment has no preexisting .mypy_cache and where an unsuspecting user may accidentally cause the duplicate-module behavior. mypy fails and suggests it's because of the missing cache directory.
(Deeper demonstration is in the reproducible example linked above. In short, if mypy finds an empty .mypy_cache folder, it will report the duplicate module issue. If we place __init__.py in a and b and remove .mypy_cache, mypy will install the cache correctly and report the typing error.)
My Environment
Ubuntu 20
Python 3.6 (this older version is from the production codebase in which we found this issue)
Hi there. Do we expect this issue to be resolved at any moment with any mypy releases? Or the only workaround now is to create .mypy_cache/ in our pipelines? Thanks!
I just catch same problem in my project and after spending a severals hours found this solution. And i tried your... Okay, not your, sorry, I tried mypy . --install-types --non-interactive
But the problem is very annoying and I hope that my advice can help someone.
Activity
berislav-harbr commentedon Dec 10, 2021
I'd like to add that I had the same issue when
sqlalchemy-stubswas not installed.debug mypy error report masked by 'error: --install-types failed (no …
KotlinIsland commentedon Mar 31, 2022
Minified example
If you create the cache directory (empty) then it has:
Why does this check even exist?
Workaround for mypy complaining about the cache
fix: create mypy cache directory
fix: create mypy cache directory
fix: create mypy cache directory (#5240)
Workaround for mypy complaining about the cache
Dobatymo commentedon May 17, 2024
Still an issue with
mypy==1.10.0. For me aerror: Duplicate module named "xxx" (also at ".\yyy\xxx.py")error was hidden that way.amotl commentedon Jun 4, 2024
Hi there. Thanks for creating this issue ticket. We would like to add that the same problem is also tripping us on a CI/GHA integration.
jlin880 commentedon Jun 11, 2024
Hi there. Do we expect this issue to be resolved at any moment with any mypy releases? Or the only workaround now is to create .mypy_cache/ in our pipelines? Thanks!
alanbchristie commentedon Jun 19, 2024
A follow-up to @jlin880 ...
mkdir .mypy_cachehelps me get around mypy complaining about it not being there but I shouldn't have to do this.move py.typed to correct places (#403)
See python/mypy#10768
5 remaining items
CHuKeR commentedon Nov 28, 2024
I just catch same problem in my project and after spending a severals hours found this solution. And i tried your... Okay, not your, sorry, I tried mypy . --install-types --non-interactive
But the problem is very annoying and I hope that my advice can help someone.
Fix --install-types masking failure details (#17485)
Update code-quality-checks.yml: remove workaround
Update code-quality-checks.yml: remove workaround
Update code-quality-checks.yml: remove workaround
Update code-quality-checks.yml: remove workaround
move py.typed to correct places (#403)
move py.typed to correct places (#403)
move py.typed to correct places (#403)
move py.typed to correct places (#403)
E2E POC for python telemetry for connect logs (#581)
Add optional telemetry support to the python connector (#628)
Update code-quality-checks.yml: remove workaround
fix: mkdir .mypy_cache before --install-types to avoid cold-cache fai…