[ty] Fix Step 5 overload ambiguity for multi-argument calls#23576
[ty] Fix Step 5 overload ambiguity for multi-argument calls#23576charliermarsh wants to merge 2 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.72%. The percentage of expected errors that received a diagnostic held steady at 82.85%. The number of fully passing files held steady at 74/132. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownsphinx
prefect
flake8
trio
|
|
e46cb73 to
d0df10a
Compare
|
(Going to revert back to |
509843f to
47e8714
Compare
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
type-assertion-failure |
27 | 0 | 3 |
| Total | 27 | 0 | 3 |
Raw diff (30 changes)
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ tests/frame/test_frame.py:2849:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/frame/test_frame.py:2850:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/frame/test_frame.py:2851:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/indexes/test_mul.py:96:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Index[Any]`
+ tests/indexes/test_mul.py:102:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Index[Any]`
+ tests/indexes/test_sub.py:91:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Index[Any]`
+ tests/indexes/test_sub.py:97:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Index[Any]`
+ tests/series/test_add.py:162:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_add.py:168:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_add.py:174:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_add.py:180:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:126:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:138:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:144:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:159:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:165:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:171:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_mul.py:177:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:129:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:141:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:147:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:162:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:168:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:174:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
+ tests/series/test_sub.py:180:11 error[type-assertion-failure] Type `Unknown` does not match asserted type `Series[Any]`
scipy-stubs (https://github.com/scipy/scipy-stubs)
+ tests/linalg/test__procrustes.pyi:25:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `tuple[Unknown, float64]`
+ tests/linalg/test__procrustes.pyi:26:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `tuple[Unknown, float64]`
- tests/linalg/test__procrustes.pyi:21:1 error[type-assertion-failure] Type `tuple[Unknown, float64]` does not match asserted type `tuple[Unknown, floating[_32Bit] | float64]`
+ tests/linalg/test__procrustes.pyi:21:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `tuple[Unknown, floating[_32Bit] | float64]`
- tests/linalg/test__procrustes.pyi:24:1 error[type-assertion-failure] Type `tuple[Unknown, float64]` does not match asserted type `tuple[Unknown, floating[_32Bit] | float64]`
+ tests/linalg/test__procrustes.pyi:24:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `tuple[Unknown, floating[_32Bit] | float64]`
- tests/linalg/test__procrustes.pyi:27:1 error[type-assertion-failure] Type `tuple[Unknown, float64]` does not match asserted type `tuple[Unknown, floating[_32Bit] | float64]`
+ tests/linalg/test__procrustes.pyi:27:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `tuple[Unknown, floating[_32Bit] | float64]`47e8714 to
987748b
Compare
|
Considering the test case added in this PR, it seems that the PR is converting the assignability check between the top materialization of the argument types which is # arg types: (A[Any], A[Any])
tuple[A[object], A[object]]and, the tuple of union of parameter types upto the specific overload: # This is at overload index 2 (which is the third overload)
# Tuple of union of parameters at same position
tuple[A[None] | A[Any], A[None] | A[Any]]To now checking assignment between the same top materialization of argument types, but doing a union of tuple of parameter types: # This is at overload index 2 (which is the third overload)
tuple[A[None], A[None]] | tuple[A[None], A[Any]] | tuple[A[Any], A[None]]which is how the step 5 is unable to filter out any overloads making the match ambiguous. I'd need to think through whether this approach is correct but for context, here's the discussion on the original approach: https://discord.com/channels/1039017663004942429/1380022837947138098/1380368239095316480 Need to hop into a 1:1, but want to look at a couple of ecosystem diagnostics that have been added. |
|
This seems like a regression?
But, on considering |
Oh, this seems probably like a separate issue. This is the minimal code: import pandas as pd
def _():
p = pd.Period("2012-1-1", freq="D")
as_period_index = pd.period_range("2012-1-1", periods=10, freq="D")
as_period_series = pd.Series(as_period_index)
offset_series = as_period_series - as_period_series
reveal_type(offset_series)
reveal_type(p + offset_series)Here, the inferred type of def _(s: pd.Series[Any]):
# This is `Unknown` in this PR but `Series[Any]` on `main`
reveal_type(s - s) |
987748b to
e726461
Compare
Summary
We now preserve cross-argument correlation by evaluating a union of per-overload parameter tuples, instead of collapsing parameters independently.
See: astral-sh/ty#2906.