Fix overloads with a generic self: dropped when matching a Protocol#3975
Open
jorenham wants to merge 1 commit into
Open
Fix overloads with a generic self: dropped when matching a Protocol#3975jorenham wants to merge 1 commit into
self: dropped when matching a Protocol#3975jorenham wants to merge 1 commit into
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: jax (https://github.com/google/jax)
+ ERROR jax/_src/lax/linalg.py:1066:74-78: Argument `list[signedinteger[_32Bit]]` is not assignable to parameter `broadcast_dimensions` with type `Sequence[int]` in function `jax._src.lax.lax.broadcast_in_dim` [bad-argument-type]
+ ERROR jax/_src/lax/linalg.py:1068:63-67: Argument `list[signedinteger[_32Bit]]` is not assignable to parameter `broadcast_dimensions` with type `Sequence[int]` in function `jax._src.lax.lax.broadcast_in_dim` [bad-argument-type]
scipy-stubs (https://github.com/scipy/scipy-stubs)
+ ERROR tests/sparse/test_csr.pyi:196:1-2: Unused `# pyrefly: ignore` comment for code(s): assert-type [unused-ignore]
DateType (https://github.com/glyph/DateType)
- ERROR src/datetype/test/test_datetype.py:49:38-54: `Time[None]` is not assignable to `NaiveTime` [bad-assignment]
colour (https://github.com/colour-science/colour)
- ERROR colour/temperature/cie_d.py:113:21-118:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[Any], **dict[str, str | dict[str, float]]) [no-matching-overload]
+ ERROR colour/temperature/cie_d.py:113:21-118:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]], **dict[str, str | dict[str, float]]) [no-matching-overload]
- ERROR colour/temperature/hernandez1999.py:176:21-181:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=Unknown, args=tuple[Any], **dict[str, str | dict[str, float]]) [no-matching-overload]
+ ERROR colour/temperature/hernandez1999.py:176:21-181:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=Unknown, args=tuple[ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]], **dict[str, str | dict[str, float]]) [no-matching-overload]
- ERROR colour/temperature/kang2002.py:112:21-117:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[Any], **dict[str, str | dict[str, float]]) [no-matching-overload]
+ ERROR colour/temperature/kang2002.py:112:21-117:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]], **dict[str, str | dict[str, float]]) [no-matching-overload]
- ERROR colour/temperature/krystek1985.py:117:21-122:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], uv: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[Any], **dict[str, str | dict[str, float]]) [no-matching-overload]
+ ERROR colour/temperature/krystek1985.py:117:21-122:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], uv: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]], **dict[str, str | dict[str, float]]) [no-matching-overload]
- ERROR colour/temperature/mccamy1992.py:160:21-165:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=Unknown, args=tuple[Any], **dict[str, str | dict[str, float]]) [no-matching-overload]
+ ERROR colour/temperature/mccamy1992.py:160:21-165:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((xy: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=Unknown, args=tuple[ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]], **dict[str, str | dict[str, float]]) [no-matching-overload]
- ERROR colour/temperature/planck1900.py:120:21-125:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], uv: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[Any], **dict[str, str | dict[str, float]]) [no-matching-overload]
+ ERROR colour/temperature/planck1900.py:120:21-125:14: No matching overload found for function `scipy.optimize._minimize.minimize` called with arguments: ((CCT: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]], uv: ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]) -> DTypeFloat, x0=list[int], args=tuple[ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]]], **dict[str, str | dict[str, float]]) [no-matching-overload]
|
Contributor
Author
So all primer changes are good news. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
filter_overloads_by_self_typedropped any overload whoseself:mentions the overload's own type params, sinceis_subset_eq(receiver, self)checks against a rigid, unsolvable variable. Substitute those params withAnyfirst, so the receiver is matched against a gradualself:.An overload whose
self:mentions its own type parameters is matched gradually by substituting those parameters withAny (self: Arr[S, T] -> Arr[Any, Any]), which is exact for the realistic single-occurrence case and only over-accepts the presumably niche degenerate repeated-parameter case,(self: C[Z, Z]), same as mypy and pyright.Fixes #3974
Test Plan
Regression tests added