Skip to content

type: ignore only works when deleting mypy cache #9777

Closed
@l0b0

Description

@l0b0

Bug Report

mypy reliably fails to take into account a type: ignore comment on the second run after deleting the cache.

To Reproduce

  1. rm -r .mypy_cache
  2. mypy .
  3. mypy .

Expected Behavior

The second run of mypy should behave exactly the same as the first run.

Actual Behavior

$ rm -r .mypy_cache
$ mypy .
Success: no issues found in 23 source files
$ mypy .
infra/app.py:9: error: Skipping analyzing 'aws_cdk': found module but no type hints or library stubs
infra/datalake/datalake_stack.py:4: error: Skipping analyzing 'aws_cdk': found module but no type hints or library stubs
infra/datalake/datalake_stack.py:4: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 2 errors in 2 files (checked 23 source files)

Some subsequent runs will succeed, but I've not looked into the pattern. I was able to run while pre-commit run --all-files mypy; do rm -r .mypy_cache; done a bunch of rounds without failure.

Your Environment

  • Mypy version used: 0.790
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.8.6
  • Operating system and version: Arch Linux

Relevant commit

Workaround

Add --no-incremental to the mypy arguments.

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