Skip to content

Line number missing from "note" message when running with cache #20017

Closed as duplicate

Description

@pmantion

Bug Report

When running with cached results, Mypy does not display the line number in "note" messages. When running with no cached results (or an empty cache), the line number is correctly present inside the message.

To Reproduce

# file example_stubs.pyi
def foo(self) -> None: ...
# file example.pyi
from example_stubs import foo
    
foo(inexistent_arg=42)

Steps to reproduce:

rm -rf .mypy_cache
python -m mypy example.py  # First run (no cache)
python -m mypy example.py  # Second run (with cache)

Expected Behavior (without cache)

Output of Mypy is:

example.py:3: error: Unexpected keyword argument "inexistent_arg" for "foo"  [call-arg]
example_stubs.pyi:1: note: "foo" defined here
Found 1 error in 1 file (checked 1 source file)

Actual Behavior (with cache)

When the Mypy cache is present, the output of Mypy is:

example.py:3: error: Unexpected keyword argument "inexistent_arg" for "foo"  [call-arg]
example_stubs.pyi: note: "foo" defined here
Found 1 error in 1 file (checked 1 source file)

Note the missing line number (1) just after example_stubes.pyi: and before note: "foo" defined here inside the middle line of the output.

Your Environment

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

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