request-cache with --no-implicit-reexport cause an AssertionError #11025
Copy link
Copy link
Closed
Labels
Description
Crash Report
Only with --no-implicit-reexport, adding from requests_cache import CachedSession into any file, including an empty file cause this error: AssertionError: Definition of requests_cache.patcher.BaseCache is unexpectedly incomplete
Traceback
$ mypy --no-implicit-reexport app/test.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mypy/__main__.py", line 11, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 87, in main
File "mypy/main.py", line 165, in run_build
File "mypy/build.py", line 179, in build
File "mypy/build.py", line 254, in _build
File "mypy/build.py", line 2697, in dispatch
File "mypy/build.py", line 3021, in process_graph
File "mypy/build.py", line 3138, in process_stale_scc
File "mypy/build.py", line 2288, in write_cache
File "mypy/build.py", line 1475, in write_cache
File "mypy/nodes.py", line 313, in serialize
File "mypy/nodes.py", line 3149, in serialize
File "mypy/nodes.py", line 3083, in serialize
AssertionError: Definition of requests_cache.patcher.BaseCache is unexpectedly incomplete```
To Reproduce
# test.py
from requests_cache import CachedSession
On the command line:
$ mypy --no-implicit-reexport test.py
Note: removing the .mypy_chache did not help.
Your Environment
- request-cache used: 0.7.3
- Mypy version used: 0.910
- Mypy command-line flags: --no-implicit-reexport
- Mypy configuration options from
mypy.ini(and other config files): not used - Python version used: 3.9.1
- Operating system and version: macOS Version 11.3.1
Reactions are currently unavailable
Activity
JWCook commentedon Aug 28, 2021
Well, that's curious. I also reproduced this with the latest changes in the requests-cache
masterbranch.If I modify the import in
requests_cache/patcher.pytoThe error goes away, but if I alias it to something else:
I get the same
AssertionError.I don't know what's going on there, but if you have suggestions for improving the type hints or exports in requests-cache, you're welcome to create an issue there: https://github.com/reclosedev/requests-cache/issues
boehmseb commentedon Sep 20, 2021
Hi,
I just stumbled across the same problem. While I also have no idea what's going on, I can say that mypy only crashes from version 0.800 onwards. No crash with earlier versions. Maybe this helps identifying the problem.
Remove requests_cache for now.
fix: 🐛 try to make mypy test pass
Fix crash involving explicit reexport, import cycle, wildcard (#11632)
Fix crash involving explicit reexport, import cycle, wildcard (#11632)
Fix crash involving explicit reexport, import cycle, wildcard (python…
fix: 🐛 try to make mypy test pass
Initial implementation of parallel type checking (#20280)