You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression: false positive about overload item never being matched #16338
This fragment generates a false positive, starting from #15913:
fromtypingimportoverload, AnyclassC:
@overloaddeff(self, e: str, **kwargs) ->str: ...
@overload# error: Overloaded function signature 2 will never be matched: signature 1's# parameter type(s) are the same or broaderdeff(self, *args, **kwargs) ->Any: ...
deff(self, *args, **kwargs):
pass
The signature of item 2 is wider than item 1 due to accepting an arbitrary number of positional arguments and with arbitrary types, so this is a false positive.
This is one of those case when I ask myself how did this ever work, and it turns out it didn't. It turns out having (*args: Any, **kwargs: Any) as a fallback overload caused false positives almost always. So this is not really a regression, now mypy is consistently broken, LOL.
Anyway, the fix is in #16343, it turns out we never propagated is_proper_subtype flag to is_callable_compatible(). This is a major change, let's see how bad the fallout will be.
Activity
ilevkivskyi commentedon Oct 27, 2023
This is one of those case when I ask myself how did this ever work, and it turns out it didn't. It turns out having
(*args: Any, **kwargs: Any)as a fallback overload caused false positives almost always. So this is not really a regression, now mypy is consistently broken, LOL.Anyway, the fix is in #16343, it turns out we never propagated
is_proper_subtypeflag tois_callable_compatible(). This is a major change, let's see how bad the fallout will be.Properly use proper subtyping for callables (#16343)