- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 3k
 
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-incremental
Description
Bug Report
When mypy displays "note" messages for overloaded __init__ methods with cache enabled, it incorrectly shows the class name instead of __init__. This only occurs when the overloaded class is defined in a stub file (.pyi).
To Reproduce
# file:example_stubs.pyi
from typing import overload
class Foo:
    @overload
    def __init__(self) -> None: ...
    @overload
    def __init__(self, bar: str | None) -> None: ...# file: example.py
from example_stubs import Foo
Foo(wrong_arg_name=1)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: No overload variant of "Foo" matches argument type "int"  [call-overload]
example.py:3: note: Possible overload variants:
example.py:3: note:     def __init__(self) -> Foo
example.py:3: note:     def __init__(self, bar: str | None) -> Foo
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: No overload variant of "Foo" matches argument type "int"  [call-overload]
example.py:3: note: Possible overload variants:
example.py:3: note:     def Foo(self) -> Foo
example.py:3: note:     def Foo(self, bar: str | None) -> Foo
Found 1 error in 1 file (checked 1 source file)
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
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-incremental