Skip to content

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

Closed

Description

@hauntsaninja

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

Activity

  1. hauntsaninja commented on Jan 13, 2025

    @hauntsaninja
    CollaboratorAuthor

    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}
    
  2. added a commit that references this issue on Jan 13, 2025
    fde46b5
  3. hauntsaninja commented on Jan 13, 2025

    @hauntsaninja
    CollaboratorAuthor

    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
    
  4. added a commit that references this issue on Jan 14, 2025
    d7ebe2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions