Repository navigation
Speed up type evaluation by deferring unused diagnostics and caching context-independent speculative args - #12092
Draft
Bill Schnurr (bschnurr) wants to merge 4 commits into
Draft
Bill Schnurr (bschnurr) wants to merge 4 commits into
Bill Schnurr (bschnurr) wants to merge 4 commits into
Conversation
…context-independent speculative args - Avoid building unused DiagnosticAddendum trees in assignClass / assignType when no diagnostics are collected (e.g., overload resolution and speculative checks). - Cache context-independent argument expressions across overload evaluations (both statically for simple expressions and dynamically via SpeculativeTypeEntry.isContextIndependent when inferenceContext.expectedType is not read). - Defer reading inferenceContext.expectedType in validateArgTypesWithContext until specialization is needed, remove redundant makeInferenceContext copying in validateCallForFunction, and skip duplicate expected-type assignType checks in getTypeOfExpressionWithCache during speculative validateArgType. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5ff5a8fd-cdd9-4386-b8d9-e74377cd287e
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
🟢 Pyright CLI QA —
|
…iagAddendum Remove isExpressionContextIndependent (string literals, names, member accesses, and index expressions can depend on expectedType, e.g. LiteralString in ibis) and rely solely on dynamic inferenceContextRead tracking. Also keep populating expectedTypeDiagAddendum on failed expected-type checks even in speculative mode so cached results used for diagnostics retain full addendum lines (fixing sympy and other mypy_primer diffs) while still skipping DiagnosticAddendum allocation on the common passing path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5ff5a8fd-cdd9-4386-b8d9-e74377cd287e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5ff5a8fd-cdd9-4386-b8d9-e74377cd287e
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: ibis (https://github.com/ibis-project/ibis)
- .../projects/ibis/ibis/common/patterns.py:581:26 - error: Argument of type "Generator[str | Unknown, None, None]" cannot be assigned to parameter "iterable" of type "Iterable[LiteralString]" in function "join"
- "Generator[str | Unknown, None, None]" is not assignable to "Iterable[LiteralString]"
- Type parameter "_T_co@Iterable" is covariant, but "str | Unknown" is not a subtype of "LiteralString"
- Type "str | Unknown" is not assignable to type "LiteralString"
- "str" is not assignable to "LiteralString" (reportArgumentType)
- 7235 errors, 247 warnings, 0 informations
+ 7234 errors, 247 warnings, 0 informations
sympy (https://github.com/sympy/sympy)
- .../projects/sympy/sympy/matrices/expressions/tests/test_kronecker.py:115:44 - error: Argument of type "dict[MatrixSymbol, MutableDenseMatrix]" cannot be assigned to parameter "arg1" of type "Iterable[tuple[Basic | complex, Basic | complex]]" in function "subs"
+ .../projects/sympy/sympy/matrices/expressions/tests/test_kronecker.py:115:44 - error: Argument of type "dict[MatrixSymbol, MutableDenseMatrix]" cannot be assigned to parameter "arg1" of type "Iterable[tuple[Basic | complex, Basic | complex]]" in function "subs" (reportArgumentType)
- "MatrixSymbol" is not assignable to "tuple[Basic | complex, Basic | complex]"
- "MatrixSymbol" is not assignable to "tuple[Basic | complex, Basic | complex]" (reportArgumentType)
- .../projects/sympy/sympy/matrices/expressions/tests/test_kronecker.py:119:45 - error: Argument of type "dict[MatrixSymbol, MutableDenseMatrix]" cannot be assigned to parameter "arg1" of type "Iterable[tuple[Basic | complex, Basic | complex]]" in function "subs"
+ .../projects/sympy/sympy/matrices/expressions/tests/test_kronecker.py:119:45 - error: Argument of type "dict[MatrixSymbol, MutableDenseMatrix]" cannot be assigned to parameter "arg1" of type "Iterable[tuple[Basic | complex, Basic | complex]]" in function "subs" (reportArgumentType)
- "MatrixSymbol" is not assignable to "tuple[Basic | complex, Basic | complex]"
- "MatrixSymbol" is not assignable to "tuple[Basic | complex, Basic | complex]" (reportArgumentType)
- .../projects/sympy/sympy/ntheory/continued_fraction.py:249:30 - error: Cannot access attribute "radsimp" for class "Basic"
- Attribute "radsimp" is unknown (reportAttributeAccessIssue)
- "dict[Expr, int]" is not assignable to "Mapping[Expr, Expr]"
+ "dict[Expr, int]" is not assignable to "Mapping[Tbasic@xreplace, Expr]"
- "dict[Expr, int]" is not assignable to "Mapping[Expr, Expr]"
+ "dict[Expr, int]" is not assignable to "Mapping[Tbasic@xreplace, Expr]"
- .../projects/sympy/sympy/physics/quantum/boson.py:147:48 - error: Operator "-" not supported for types "Expr | Basic" and "Literal[1]"
+ .../projects/sympy/sympy/physics/quantum/boson.py:147:48 - error: Operator "-" not supported for types "Unknown | Basic" and "Literal[1]"
- .../projects/sympy/sympy/physics/quantum/boson.py:149:25 - error: Operator "+" not supported for types "Expr | Basic" and "Literal[1]"
+ .../projects/sympy/sympy/physics/quantum/boson.py:149:25 - error: Operator "+" not supported for types "Unknown | Basic" and "Literal[1]"
- .../projects/sympy/sympy/physics/quantum/boson.py:149:52 - error: Operator "+" not supported for types "Expr | Basic" and "Literal[1]"
+ .../projects/sympy/sympy/physics/quantum/boson.py:149:52 - error: Operator "+" not supported for types "Unknown | Basic" and "Literal[1]"
- .../projects/sympy/sympy/physics/quantum/boson.py:209:30 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "x" of type "SupportsAbs[_T@abs]" in function "abs"
+ .../projects/sympy/sympy/physics/quantum/boson.py:209:30 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "x" of type "SupportsAbs[_T@abs]" in function "abs"
- Type "Expr | Basic" is not assignable to type "SupportsAbs[_T@abs]"
+ Type "Unknown | Basic" is not assignable to type "SupportsAbs[_T@abs]"
- .../projects/sympy/sympy/physics/quantum/boson.py:209:67 - error: Operator "*" not supported for types "Expr" and "Expr | Basic"
+ .../projects/sympy/sympy/physics/quantum/boson.py:209:67 - error: Operator "*" not supported for types "Expr" and "Unknown | Basic"
- .../projects/sympy/sympy/physics/quantum/boson.py:213:20 - error: Operator "*" not supported for types "Expr | Basic" and "Self@BosonCoherentKet"
+ .../projects/sympy/sympy/physics/quantum/boson.py:213:20 - error: Operator "*" not supported for types "Unknown | Basic" and "Self@BosonCoherentKet"
- .../projects/sympy/sympy/physics/quantum/boson.py:242:20 - error: Operator "*" not supported for types "Expr | Basic" and "Self@BosonCoherentBra"
+ .../projects/sympy/sympy/physics/quantum/boson.py:242:20 - error: Operator "*" not supported for types "Unknown | Basic" and "Self@BosonCoherentBra"
- .../projects/sympy/sympy/physics/quantum/cartesian.py:173:20 - error: Operator "*" not supported for types "Expr" and "Expr | Basic"
+ .../projects/sympy/sympy/physics/quantum/cartesian.py:173:20 - error: Operator "*" not supported for types "Expr" and "Unknown | Basic"
- .../projects/sympy/sympy/physics/quantum/cartesian.py:282:20 - error: Operator "*" not supported for types "ImaginaryUnit" and "Expr | Basic"
+ .../projects/sympy/sympy/physics/quantum/cartesian.py:282:20 - error: Operator "*" not supported for types "ImaginaryUnit" and "Unknown | Basic"
- Return type mismatch: base method returns type "tuple[Expr, ...]", override returns type "Tuple"
+ Return type mismatch: base method returns type "tuple[Unknown, ...]", override returns type "Tuple"
- "Tuple" is not assignable to "tuple[Expr, ...]" (reportIncompatibleMethodOverride)
+ "Tuple" is not assignable to "tuple[Unknown, ...]" (reportIncompatibleMethodOverride)
- .../projects/sympy/sympy/physics/quantum/gate.py:377:26 - error: Cannot access attribute "targets" for class "Expr"
- Attribute "targets" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:382:22 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
+ .../projects/sympy/sympy/physics/quantum/gate.py:382:22 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
- Type "Expr | Basic" is not assignable to type "Iterable[_T_co@tuple]"
+ Type "Unknown | Basic" is not assignable to type "Iterable[_T_co@tuple]"
- .../projects/sympy/sympy/physics/quantum/gate.py:394:26 - error: Cannot access attribute "get_target_matrix" for class "Expr"
- Attribute "get_target_matrix" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:404:27 - error: Cannot access attribute "targets" for class "Expr"
- Attribute "targets" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:455:26 - error: Cannot access attribute "gate_name" for class "Expr"
- Attribute "gate_name" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:456:27 - error: Cannot access attribute "plot_gate_plus" for class "Expr"
- Attribute "plot_gate_plus" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:457:28 - error: Cannot access attribute "gate_name" for class "Expr"
- Attribute "gate_name" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:460:27 - error: Cannot access attribute "plot_gate" for class "Expr"
- Attribute "plot_gate" is unknown (reportAttributeAccessIssue)
- Attribute "plot_gate" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/physics/quantum/gate.py:462:23 - error: Cannot access attribute "plot_gate" for class "Expr"
- .../projects/sympy/sympy/physics/quantum/gate.py:547:22 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
+ .../projects/sympy/sympy/physics/quantum/gate.py:547:22 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
- Type "Expr | Basic" is not assignable to type "Iterable[_T_co@tuple]"
+ Type "Unknown | Basic" is not assignable to type "Iterable[_T_co@tuple]"
- .../projects/sympy/sympy/physics/quantum/gate.py:591:27 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
+ .../projects/sympy/sympy/physics/quantum/gate.py:591:27 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
- Type "Expr | Basic" is not assignable to type "ConvertibleToInt"
+ Type "Unknown | Basic" is not assignable to type "ConvertibleToInt"
- .../projects/sympy/sympy/physics/quantum/gate.py:591:27 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
+ .../projects/sympy/sympy/physics/quantum/gate.py:591:27 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
- Type "Expr | Basic" is not assignable to type "ConvertibleToInt"
+ Type "Unknown | Basic" is not assignable to type "ConvertibleToInt"
- .../projects/sympy/sympy/physics/quantum/gate.py:727:27 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
+ .../projects/sympy/sympy/physics/quantum/gate.py:727:27 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
- Type "Expr | Basic" is not assignable to type "ConvertibleToInt"
+ Type "Unknown | Basic" is not assignable to type "ConvertibleToInt"
- .../projects/sympy/sympy/physics/quantum/gate.py:727:27 - error: Argument of type "Expr | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
+ .../projects/sympy/sympy/physics/quantum/gate.py:727:27 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
- Type "Expr | Basic" is not assignable to type "ConvertibleToInt"
+ Type "Unknown | Basic" is not assignable to type "ConvertibleToInt"
... (truncated 328 lines) ...
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- "__getitem__" is an incompatible type (reportArgumentType)
+ "__getitem__" is an incompatible type
+ ... (reportArgumentType)
- .../projects/scikit-learn/sklearn/impute/_base.py:155:45 - error: Argument of type "tuple[SparseABC | Unknown, Unknown]" cannot be assigned to parameter "blocks" of type "Sequence[_spbase[Any, tuple[Any, ...]]]" in function "__call__"
+ .../projects/scikit-learn/sklearn/impute/_base.py:155:44 - error: Argument of type "tuple[SparseABC | Unknown, Unknown]" cannot be assigned to parameter "blocks" of type "Sequence[_spbase[Any, tuple[Any, ...]]]" in function "__call__"
+ "tuple[SparseABC | Unknown, Unknown]" is not assignable to "Sequence[_spbase[Any, tuple[Any, ...]]]"
+ Type parameter "_T_co@Sequence" is covariant, but "SparseABC | Unknown" is not a subtype of "_spbase[Any, tuple[Any, ...]]"
- Type "SparseABC | Unknown" is not assignable to type "_spbase[Any, tuple[Any, ...]]"
+ Type "SparseABC | Unknown" is not assignable to type "_spbase[Any, tuple[Any, ...]]"
- "SparseABC" is not assignable to "_spbase[Any, tuple[Any, ...]]" (reportArgumentType)
+ "SparseABC" is not assignable to "_spbase[Any, tuple[Any, ...]]" (reportArgumentType)
- .../projects/scikit-learn/sklearn/linear_model/_least_angle.py:803:34 - error: Argument of type "tuple[slice[None, int | Unknown, None], slice[int | Unknown, None, None]]" cannot be assigned to parameter "key" of type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" in function "__getitem__"
+ .../projects/scikit-learn/sklearn/linear_model/_least_angle.py:803:34 - error: Argument of type "tuple[slice[None, int, None], slice[int, None, None]]" cannot be assigned to parameter "key" of type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" in function "__getitem__"
- Type "tuple[slice[None, int | Unknown, None], slice[int | Unknown, None, None]]" is not assignable to type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]"
+ Type "tuple[slice[None, int, None], slice[int, None, None]]" is not assignable to type "SupportsIndex | slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]"
- "tuple[slice[None, int | Unknown, None], slice[int | Unknown, None, None]]" is incompatible with protocol "SupportsIndex"
+ "tuple[slice[None, int, None], slice[int, None, None]]" is incompatible with protocol "SupportsIndex"
- "tuple[slice[None, int | Unknown, None], slice[int | Unknown, None, None]]" is not assignable to "slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" (reportArgumentType)
+ "tuple[slice[None, int, None], slice[int, None, None]]" is not assignable to "slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]" (reportArgumentType)
+ "__len__" is not present
+ ... (reportArgumentType)
+ .../projects/scikit-learn/sklearn/metrics/cluster/_unsupervised.py:146:18 - error: No overloads for "mean" match the provided arguments (reportCallIssue)
+ .../projects/scikit-learn/sklearn/metrics/cluster/_unsupervised.py:146:26 - error: Argument of type "Array" cannot be assigned to parameter "a" of type "_ArrayLikeComplex_co | _ArrayLikeObject_co" in function "mean"
+ Type "Array" is not assignable to type "_ArrayLikeComplex_co | _ArrayLikeObject_co"
+ "Array" is incompatible with protocol "_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]"
+ "__array__" is not present
+ "Array" is incompatible with protocol "_NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]]"
+ "__len__" is not present
+ "__contains__" is not present
+ "__iter__" is not present
+ "__reversed__" is not present
+ ... (reportArgumentType)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:209:13 - error: Argument of type "Array" cannot be assigned to parameter "rel" of type "float | Decimal | timedelta | None" in function "approx"
+ Type "Array" is not assignable to type "float | Decimal | timedelta | None"
+ "Array" is not assignable to "float"
+ "Array" is not assignable to "Decimal"
+ "Array" is not assignable to "timedelta"
+ "Array" is not assignable to "None" (reportArgumentType)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:292:5 - error: No overloads for "assert_allclose" match the provided arguments (reportCallIssue)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:292:21 - error: Argument of type "Array" cannot be assigned to parameter "actual" of type "_NumericArrayLike" in function "assert_allclose"
+ Type "Array" is not assignable to type "_NumericArrayLike"
+ "Array" is incompatible with protocol "_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]"
+ "__array__" is not present
+ "Array" is incompatible with protocol "_NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]]"
+ "__len__" is not present
+ "__contains__" is not present
+ "__iter__" is not present
+ "__reversed__" is not present
+ ... (reportArgumentType)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:292:47 - error: Argument of type "Array" cannot be assigned to parameter "desired" of type "_NumericArrayLike" in function "assert_allclose"
+ Type "Array" is not assignable to type "_NumericArrayLike"
+ "Array" is incompatible with protocol "_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]"
+ "__array__" is not present
+ "Array" is incompatible with protocol "_NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]]"
+ "__len__" is not present
+ "__contains__" is not present
+ "__iter__" is not present
+ "__reversed__" is not present
+ ... (reportArgumentType)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:308:5 - error: No overloads for "assert_allclose" match the provided arguments (reportCallIssue)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:308:21 - error: Argument of type "Array" cannot be assigned to parameter "actual" of type "_NumericArrayLike" in function "assert_allclose"
+ Type "Array" is not assignable to type "_NumericArrayLike"
+ "Array" is incompatible with protocol "_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]"
+ "__array__" is not present
+ "Array" is incompatible with protocol "_NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]]"
+ "__len__" is not present
+ "__contains__" is not present
+ "__iter__" is not present
+ "__reversed__" is not present
+ ... (reportArgumentType)
+ .../projects/scikit-learn/sklearn/metrics/cluster/tests/test_unsupervised.py:308:47 - error: Argument of type "Array" cannot be assigned to parameter "desired" of type "_NumericArrayLike" in function "assert_allclose"
+ Type "Array" is not assignable to type "_NumericArrayLike"
+ "Array" is incompatible with protocol "_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]"
+ "__array__" is not present
+ "Array" is incompatible with protocol "_NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]]"
+ "__len__" is not present
+ "__contains__" is not present
+ "__iter__" is not present
+ "__reversed__" is not present
+ ... (reportArgumentType)
+ "tuple[coo_array[Any, tuple[Any, ...]] | str | tuple[str, str] | Unknown | Any | tuple[Unknown, Unknown | Any] | <subclass of SparseABC and spmatrix[Any]> | SparseABC, ndarray[_AnyShape, dtype[float64]]]" is not assignable to "Sequence[_CanStack[_StackedSparseMatrix[Any]]]"
+ Type parameter "_T_co@Sequence" is covariant, but "coo_array[Any, tuple[Any, ...]] | str | tuple[str, str] | Unknown | Any | tuple[Unknown, Unknown | Any] | <subclass of SparseABC and spmatrix[Any]> | SparseABC | ndarray[_AnyShape, dtype[float64]]" is not a subtype of "_CanStack[_StackedSparseMatrix[Any]]"
- Type "coo_array[Any, tuple[Any, ...]] | str | tuple[str, str] | Unknown | Any | tuple[Unknown, Unknown | Any] | <subclass of SparseABC and spmatrix[Any]> | SparseABC" is not assignable to type "_CanStack[_StackedSparseMatrix[Any]]"
+ Type "coo_array[Any, tuple[Any, ...]] | str | tuple[str, str] | Unknown | Any | tuple[Unknown, Unknown | Any] | <subclass of SparseABC and spmatrix[Any]> | SparseABC | ndarray[_AnyShape, dtype[float64]]" is not assignable to type "_CanStack[_StackedSparseMatrix[Any]]"
- "SparseABC" is incompatible with protocol "_CanStack[_StackedSparseMatrix[Any]]"
+ "SparseABC" is incompatible with protocol "_CanStack[_StackedSparseMatrix[Any]]"
- "__assoc_stacked__" is not present
- "ndarray[_AnyShape, dtype[float64]]" is incompatible with protocol "_CanStack[_StackedSparseMatrix[Any]]"
- "__assoc_stacked__" is not present (reportArgumentType)
+ "__assoc_stacked__" is not present (reportArgumentType)
+ .../projects/scikit-learn/sklearn/neighbors/_nca.py:313:26 - error: No overloads for "ravel" match the provided arguments (reportCallIssue)
+ .../projects/scikit-learn/sklearn/neighbors/_nca.py:313:35 - error: Argument of type "Unknown | _Array2D[float64] | NDArray[float64] | Any | None" cannot be assigned to parameter "a" of type "ArrayLike" in function "ravel"
... (truncated 9 lines) ...
comtypes (https://github.com/enthought/comtypes)
- .../projects/comtypes/comtypes/tools/tlbparser.py:180:20 - error: Type "ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to return type "ParsedType | SpecType"
- Type "ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to type "ParsedType | SpecType"
- Type "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to type "ParsedType | SpecType"
- "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to "TypeLib"
- "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to "Constant"
- "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to "External"
- "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to "CoClass"
- "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to "ComInterface"
- "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]]" is not assignable to "DispInterface"
+ .../projects/comtypes/comtypes/tools/tlbparser.py:180:20 - error: Type "ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to return type "ParsedType | SpecType"
+ Type "ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to type "ParsedType | SpecType"
+ Type "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to type "ParsedType | SpecType"
+ "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to "TypeLib"
+ "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to "Constant"
+ "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to "External"
+ "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to "CoClass"
+ "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to "ComInterface"
+ "ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]] | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType | ArrayType[ParsedType | SpecType]]]]" is not assignable to "DispInterface"
streamlit (https://github.com/streamlit/streamlit)
+ .../projects/streamlit/lib/tests/streamlit/runtime/scriptrunner_utils/query_run_stats_test.py
+ .../projects/streamlit/lib/tests/streamlit/runtime/scriptrunner_utils/query_run_stats_test.py:44:56 - error: Argument of type "type[QueryTotals]" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "type[QueryTotals]" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ "__dataclass_fields__" is defined as a ClassVar in protocol (reportArgumentType)
- 9493 errors, 39 warnings, 0 informations
+ 9494 errors, 39 warnings, 0 informations
core (https://github.com/home-assistant/core)
+ .../projects/core/homeassistant/components/bluetooth/passive_update_processor.py:44:76 - error: Argument of type "type[DeviceInfo]" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "type[DeviceInfo]" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ "__dataclass_fields__" is defined as a ClassVar in protocol (reportArgumentType)
+ .../projects/core/homeassistant/components/stream/worker.py:663:29 - error: Argument of type "type[StreamSettings]" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "type[StreamSettings]" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ "__dataclass_fields__" is defined as a ClassVar in protocol (reportArgumentType)
+ .../projects/core/homeassistant/components/zwave_js/config_flow.py:112:37 - error: Argument of type "type[Self@SecurityKeys]" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "type[Self@SecurityKeys]" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ "__dataclass_fields__" is defined as a ClassVar in protocol (reportArgumentType)
+ .../projects/core/homeassistant/components/zwave_js/config_flow.py:121:37 - error: Argument of type "Self@SecurityKeys" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "Self@SecurityKeys" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ Type "Self@SecurityKeys" is not assignable to type "type[DataclassInstance]" (reportArgumentType)
+ .../projects/core/homeassistant/components/zwave_js/config_flow.py:127:23 - error: Argument of type "Self@SecurityKeys" cannot be assigned to parameter "obj" of type "DataclassInstance" in function "asdict" (reportArgumentType)
+ .../projects/core/homeassistant/components/zwave_js/config_flow.py:139:37 - error: Argument of type "Self@SecurityKeys" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "Self@SecurityKeys" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ Type "Self@SecurityKeys" is not assignable to type "type[DataclassInstance]" (reportArgumentType)
+ .../projects/core/homeassistant/components/zwave_js/config_flow.py:143:33 - error: Argument of type "Self@SecurityKeys" cannot be assigned to parameter "class_or_instance" of type "DataclassInstance | type[DataclassInstance]" in function "fields"
+ Type "Self@SecurityKeys" is not assignable to type "DataclassInstance | type[DataclassInstance]"
+ Type "Self@SecurityKeys" is not assignable to type "type[DataclassInstance]" (reportArgumentType)
... (truncated 448 lines) ...``` |
Contributor
|
Compared candidate Release history charts were not rendered for this run. See the workflow run for details. Type checker benchmark🟢 No performance regressions detected. Regression threshold:
Pyright stats
|
… cache hits Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5ff5a8fd-cdd9-4386-b8d9-e74377cd287e
This branch has not been deployed
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
Optimizes Pyright's type evaluation hot paths during overload resolution and speculative argument checking:
DiagnosticAddendumtrees intypeCompatibility.ts/typeEvaluator.tswhen diagnostics are not requested.expectedType.SpeculativeTypeEntry.isContextIndependentinSpeculativeTypeTrackerandgetTypeOfExpressionWithCache/writeTypeCacheso non-trivial expressions (Call,BinaryOperation, etc.) that never readinferenceContext.expectedTypeare reused across overloads regardless ofexpectedType.inferenceContext.expectedTypeinvalidateArgTypesWithContextuntil afterrequiresSpecialization(returnType)is checked, and avoid redundantmakeInferenceContextcloning invalidateCallForFunction.validateArgType: Pass an internalskipExpectedTypeCheckflag fromvalidateArgTypewhen speculative mode is active, sincevalidateArgTypeimmediately runsassignTypeitself and discardstypeErrors.Benchmark (
pandas-dev/pandas, commitfff774c, 340 checked files)Measured across 3 unprofiled runs each with 0 diagnostic diffs vs baseline (
261 errors, 1 warning, 0 informations):CheckCheck)main)40.07 s35.24 s34.11 s29.15 s-17.3%isContextIndependent+skipExpectedTypeCheck+ companion member-lookup/reachability PR33.01 s–33.34 s27.96 s–28.20 s-20.0%to-20.7%Testing
pyright-internalTypeScript build — passedtypeEvaluator1–8,diagnostics,overloadResult,overloadResultController,typeCacheIsolation,typeCacheUtils) — 13/13 suites, 1,648/1,648 tests passedpandas-dev/pandasfull check — 0 diagnostic diffs vs baseline