mypy
mypy copied to clipboard
Fix dataclass/protocol crash on joining types
The root cause is hacky creation of incomplete symbols; instead switching to add_method_to_class which does the necessary housekeeping.
Fixes #15618.
Diff from mypy_primer, showing the effect of this PR on open source code:
steam.py (https://github.com/Gobot1234/steam.py)
+ steam/app.py:406: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/profile.py:193: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/profile.py:270: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/abc.py:277: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/post.py:28: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/comment.py:52: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/comment.py:54: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/leaderboard.py:80: error: Cannot use a covariant type variable as a parameter [misc]
+ steam/leaderboard.py:88: error: Cannot use a covariant type variable as a parameter [misc]
streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/runtime/state/common.py: note: In member "__mypy-replace" of class "RegisterWidgetResult":
+ lib/streamlit/runtime/state/common.py:128:12: error: Cannot use a covariant type variable as a parameter [misc]
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅