| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, looks hacky, but OK as a quick fix.
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/help.py:668: error: Argument "key" to "sort" of "list" has incompatible type "Callable[[Command[Any, [VarArg(Any), KwArg(Any)], Any]], Any] | None"; expected "Callable[[Command[Any, [VarArg(Any), KwArg(Any)], Any]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
scipy (https://github.com/scipy/scipy)
- scipy/_lib/unuran/get_and_clean_unuran.py:55: error: Cannot infer type argument 1 of "copyfileobj" [misc]
|
Sorry, something went wrong.
|
The new error in discord.py seems correct. We are now filtering the overloads of list.sort as expected. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fix type argument inference for overloaded functions with explicit self types. Filter out the overload items based on the declared and actual types of self. The implementation is best effort and does the filtering only in simple cases, to reduce the risk of regressions (primarily performance, but I worry also about infinite recursion). I added a fast path for the typical case, since without it the filtering was quite expensive.
Note that the overload item filtering already worked in many contexts. This only improves it in specific contexts -- at least when inferring generic protocol compatibility.
This is a more localized (and thus lower-risk) fix compared to #14975 (thanks @tyralla!). #14975 might still be a good idea, but I'm not comfortable merging it now, and I want a quick fix to unblock the mypy 1.12 release.
Fixes #15031. Fixes #17863.
Co-authored by @tyralla.