git clone https://github.com/schemathesis/schemathesis
cd schemathesis
mypy src/schemathesis --cache-dir=/dev/null
Traceback (most recent call last):
File "/Users/shantanujain/.virtualenvs/mypy-wxtm/bin/mypy", line 8, in <module>
sys.exit(console_entry())
~~~~~~~~~~~~~^^
File "/Users/shantanujain/dev/mypy/mypy/__main__.py", line 15, in console_entry
main()
~~~~^^
File "/Users/shantanujain/dev/mypy/mypy/main.py", line 119, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shantanujain/dev/mypy/mypy/main.py", line 203, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/Users/shantanujain/dev/mypy/mypy/build.py", line 191, in build
result = _build(
sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
)
File "/Users/shantanujain/dev/mypy/mypy/build.py", line 267, in _build
graph = dispatch(sources, manager, stdout)
File "/Users/shantanujain/dev/mypy/mypy/build.py", line 2947, in dispatch
write_deps_cache(rdeps, manager, graph)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shantanujain/dev/mypy/mypy/build.py", line 976, in write_deps_cache
assert st.meta, "Module must be either parsed or cached"
^^^^^^^
AssertionError: Module must be either parsed or cached
λ tree
.
└── s
├── __init__.py
└── internal
└── checks.py
3 directories, 2 files
λ cat s/__init__.py
λ cat s/internal/checks.py
from ..types import foo
λ mypy s --cache-dir=/dev/null --cache-fine-grained
s/internal/checks.py:1: error: Cannot find implementation or library stub for module named "s.types" [import-not-found]
s/internal/checks.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Traceback (most recent call last):
File "/Users/shantanu/.virtualenvs/mypy-crxl/bin/mypy", line 8, in <module>
sys.exit(console_entry())
^^^^^^^^^^^^^^^
File "/Users/shantanu/dev/mypy/mypy/__main__.py", line 15, in console_entry
main()
File "/Users/shantanu/dev/mypy/mypy/main.py", line 119, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shantanu/dev/mypy/mypy/main.py", line 203, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shantanu/dev/mypy/mypy/build.py", line 191, in build
result = _build(
^^^^^^^
File "/Users/shantanu/dev/mypy/mypy/build.py", line 267, in _build
graph = dispatch(sources, manager, stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shantanu/dev/mypy/mypy/build.py", line 2947, in dispatch
write_deps_cache(rdeps, manager, graph)
File "/Users/shantanu/dev/mypy/mypy/build.py", line 976, in write_deps_cache
assert st.meta, "Module must be either parsed or cached"
AssertionError: Module must be either parsed or cached
Activity
hauntsaninja commented on Jan 13, 2025
This would fix, but would be good to make a small repro. Looks related to schemathesis.internal
diff --git a/mypy/build.py b/mypy/build.py index 342331243..a7a76a51f 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -973,8 +973,10 @@ def write_deps_cache( if st.source_hash: hash = st.source_hash else: - assert st.meta, "Module must be either parsed or cached" - hash = st.meta.hash + if st.meta: + hash = st.meta.hash + else: + hash = "" meta_snapshot[id] = hash meta = {"snapshot": meta_snapshot, "deps_meta": fg_deps_meta}Fix crash with `--cache-dir=/dev/null`
hauntsaninja commented on Jan 13, 2025
Needs --cache-fine-grained to repro
λ tree . └── s ├── __init__.py └── internal └── checks.py 3 directories, 2 files λ cat s/__init__.py λ cat s/internal/checks.py from ..types import foo λ mypy s --cache-dir=/dev/null --cache-fine-grained s/internal/checks.py:1: error: Cannot find implementation or library stub for module named "s.types" [import-not-found] s/internal/checks.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports Traceback (most recent call last): File "/Users/shantanu/.virtualenvs/mypy-crxl/bin/mypy", line 8, in <module> sys.exit(console_entry()) ^^^^^^^^^^^^^^^ File "/Users/shantanu/dev/mypy/mypy/__main__.py", line 15, in console_entry main() File "/Users/shantanu/dev/mypy/mypy/main.py", line 119, in main res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/dev/mypy/mypy/main.py", line 203, in run_build res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/dev/mypy/mypy/build.py", line 191, in build result = _build( ^^^^^^^ File "/Users/shantanu/dev/mypy/mypy/build.py", line 267, in _build graph = dispatch(sources, manager, stdout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/dev/mypy/mypy/build.py", line 2947, in dispatch write_deps_cache(rdeps, manager, graph) File "/Users/shantanu/dev/mypy/mypy/build.py", line 976, in write_deps_cache assert st.meta, "Module must be either parsed or cached" AssertionError: Module must be either parsed or cachedFix crash with `--cache-fine-grained --cache-dir=/dev/null` (python#1…