python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.56k stars 2.84k forks source link

Mypy complains about issues after cache is filled #11046

Open kasium opened 3 years ago

kasium commented 3 years ago

Bug Report

I have a simpel dot dict implementation. But if I change something in my code somewhere else, mypy complains with weird errors. My current workaround is, to delete the mypy cache before each run

To Reproduce

(Write your steps here:)

  1. Clean the mypy cache
  2. Create x.py
class DotDict(dict):
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__
    __getattr__ = dict.get
  1. mypy x.py --> works fine
  2. Add a=2 to the end of x.py
  3. mypy x.py --> error
x.py:2: error: Incompatible types in assignment (expression has type "Callable[[Dict[_KT, _VT], _KT, _VT], None]", base class "object" defined the type as "Callable[[object, str, Any], None]")
x.py:3: error: Incompatible types in assignment (expression has type "Callable[[Dict[_KT, _VT], _KT], None]", base class "object" defined the type as "Callable[[object, str], None]")

Expected Behavior

No error

Actual Behavior

Error; seems like a caching issue

Your Environment

hauntsaninja commented 3 years ago

Thanks for the report! I can repro