Skip to content

Crash on schemathesis with --cache-dir=/dev/null #18454

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

Closed
hauntsaninja opened this issue Jan 13, 2025 · 2 comments · Fixed by #18457
Closed

Crash on schemathesis with --cache-dir=/dev/null #18454

hauntsaninja opened this issue Jan 13, 2025 · 2 comments · Fixed by #18457
Labels

Comments

@hauntsaninja
Copy link
Collaborator

Bisects to 3999ab88 in schemathesis

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
@hauntsaninja
Copy link
Collaborator Author

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}

hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Jan 13, 2025
Fixes python#18454

Couldn't easily repro in test suite
@hauntsaninja
Copy link
Collaborator Author

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 cached

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

Successfully merging a pull request may close this issue.

1 participant