Skip to content

[1.19 regression] output format overruled by .mypy_cache #20353

@sjoerdjob-legalsense

Description

@sjoerdjob-legalsense

Bug Report

Starting with mypy 1.19.0, the --output argument seems to be ignored when a .mypy_cache directory is present.

To Reproduce

Minimum working reproduction:

Have an incorrectly typed Python file.

# foo.py wrong: str = 5

Install the latest mypy version.

$ pip freeze librt==0.6.3 mypy==1.19.0 mypy_extensions==1.1.0 pathspec==0.12.1 typing_extensions==4.15.0 

Run mypy, with different formats:

$ rm -r .mypy_cache $ mypy foo.py $ mypy --output json foo.py $ rm -r .mypy_cache $ mypy --output json foo.py $ mypy foo.py 

Expected Behavior

Calls with --output json produce json output, calls without --output json do not (assuming nothing specified in config files).

Actual Behavior

The output format is taken from the first call

$ rm -r .mypy_cache $ mypy foo.py foo.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] Found 1 error in 1 file (checked 1 source file) $ mypy --output json foo.py foo.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment] Found 1 error in 1 file (checked 1 source file) $ rm -r .mypy_cache $ mypy --output json foo.py {"file": "foo.py", "line": 1, "column": 13, "message": "Incompatible types in assignment (expression has type \"int\", variable has type \"str\")", "hint": null, "code": "assignment", "severity": "error"} 

Your Environment

  • Mypy version used: 1.19.0
  • Mypy command-line flags: --output
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.14.0

Extra remarks

In a larger project, I have seen even --exclude being ignored on successive calls, but could not reproduce this yet in a minimal examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions