Skip to content

Errors depend on the existence of .mypy_cache #10906

Closed
@Vasniktel

Description

@Vasniktel

Bug Report

Depending on the existence of the cache, mypy can produce different errors.

To Reproduce

This issue can be reproduced using the spacy library.

  1. docker run -it python:3.9-slim bash
  2. pip install spacy==3.1.1 mypy==0.910
  3. Create a test file to check:
import spacy

spacy.cli.download('en_core_web_sm')
  1. Add mypy configs:
[mypy]
python_version = 3.9
strict = True
show_error_codes = True
pretty = True
warn_unreachable = True

Expected Behavior

One would expect that mypy errors should not depend on the cache existence.

Actual Behavior

Run mypy .. This will produce the following report the first time:

test.py:3: error: Module not callable [operator]
spacy.cli.download('en_core_web_sm')
^
Found 1 error in 1 file (checked 1 source file)

The second time (when .mypy_cache exists) you'll get:

test.py:3: error: Module has no attribute "cli" [attr-defined]
spacy.cli.download('en_core_web_sm')
^
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.910
  • Python version used: 3.9.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions