Open
Conversation
When a tuple with an unbounded entry (e.g., tuple[int, *tuple[str, ...], int]) is matched against a pattern shorter than the tuple, the unbounded entry is removed to make lengths match. However, this loses the information that the tuple was originally variadic and could have different lengths. The fix tracks when an unbounded entry is removed (removedIndeterminate flag) and marks such matches as isPotentialNoMatch=true. This prevents the entire variadic tuple from being eliminated in negative narrowing, preserving reachability of subsequent match cases.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy)
+ .../projects/sympy/sympy/solvers/tests/test_solveset.py:445:30 - error: Cannot access attribute "limit_denominator" for class "NaN"
+ Attribute "limit_denominator" is unknown (reportAttributeAccessIssue)
+ .../projects/sympy/sympy/solvers/tests/test_solveset.py:445:30 - error: Cannot access attribute "limit_denominator" for class "ComplexInfinity"
+ Attribute "limit_denominator" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/solvers/tests/test_solveset.py:620:16 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/solvers/tests/test_solveset.py:620:19 - error: Argument of type "Expr | Unknown | float" cannot be assigned to parameter "arg" of type "Expr" in function "__new__"
- Type "Expr | Unknown | float" is not assignable to type "Expr"
- "float" is not assignable to "Expr" (reportArgumentType)
- .../projects/sympy/sympy/solvers/tests/test_solveset.py:625:16 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/solvers/tests/test_solveset.py:625:19 - error: Argument of type "Expr | Unknown | float" cannot be assigned to parameter "arg" of type "Expr" in function "__new__"
- Type "Expr | Unknown | float" is not assignable to type "Expr"
- "float" is not assignable to "Expr" (reportArgumentType)
+ .../projects/sympy/sympy/stats/crv_types.py:2543:9 - error: Method "_cdf" overrides class "SingleContinuousDistribution" in an incompatible manner
+ Return type mismatch: base method returns type "None", override returns type "ComplexInfinity | NaN | Rational | Unknown"
+ Type "ComplexInfinity | NaN | Rational | Unknown" is not assignable to type "None"
+ "ComplexInfinity" is not assignable to "None" (reportIncompatibleMethodOverride)
+ .../projects/sympy/sympy/stats/crv_types.py:2722:9 - error: Method "_cdf" overrides class "SingleContinuousDistribution" in an incompatible manner
+ Return type mismatch: base method returns type "None", override returns type "Expr | NaN | ComplexInfinity | Rational | Unknown"
+ Type "Expr | NaN | ComplexInfinity | Rational | Unknown" is not assignable to type "None"
+ "Expr" is not assignable to "None" (reportIncompatibleMethodOverride)
+ .../projects/sympy/sympy/stats/frv_types.py:139:17 - error: Argument of type "NaN | ComplexInfinity | Rational | Unknown | Expr" cannot be assigned to parameter "value" of type "int" in function "__setitem__"
+ Type "NaN | ComplexInfinity | Rational | Unknown | Expr" is not assignable to type "int"
+ "Expr" is not assignable to "int" (reportArgumentType)
- .../projects/sympy/sympy/stats/joint_rv_types.py:576:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown | Infinity | NegativeInfinity | Float | Number | Expr" cannot be assigned to parameter "stop" of type "SupportsIndex" in function "__new__"
+ .../projects/sympy/sympy/stats/joint_rv_types.py:576:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" cannot be assigned to parameter "stop" of type "SupportsIndex" in function "__new__"
- Type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown | Infinity | NegativeInfinity | Float | Number | Expr" is not assignable to type "SupportsIndex"
+ Type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" is not assignable to type "SupportsIndex"
- .../projects/sympy/sympy/stats/rv_interface.py:451:42 - error: Operator "-" not supported for types "Unknown | Basic | Any" and "Rational | Unknown"
+ .../projects/sympy/sympy/stats/rv_interface.py:451:42 - error: Operator "-" not supported for types "Unknown | Basic | Any" and "Rational | NaN | ComplexInfinity"
+ Operator "-" not supported for types "Basic" and "Rational"
+ Operator "-" not supported for types "Basic" and "NaN"
- Operator "-" not supported for types "Basic" and "Rational" (reportOperatorIssue)
+ Operator "-" not supported for types "Basic" and "ComplexInfinity" (reportOperatorIssue)
- .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Expr | MatMul | Infinity | NegativeInfinity | Float | NotImplementedType | tuple[Unknown, ...] | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | ZeroMatrix | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0]"
+ .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Expr | MatMul | tuple[Unknown, ...] | Infinity | NegativeInfinity | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | ZeroMatrix | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0]"
- .../projects/sympy/sympy/stats/tests/test_finite_rv.py:247:19 - error: Argument of type "Rational | Unknown" cannot be assigned to parameter "p" of type "Half" in function "Coin"
+ .../projects/sympy/sympy/stats/tests/test_finite_rv.py:247:19 - error: Argument of type "Rational | NaN | ComplexInfinity" cannot be assigned to parameter "p" of type "Half" in function "Coin"
- Type "Rational | Unknown" is not assignable to type "Half"
+ Type "Rational | NaN | ComplexInfinity" is not assignable to type "Half"
- "Rational" is not assignable to "Half" (reportArgumentType)
+ "ComplexInfinity" is not assignable to "Half" (reportArgumentType)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:402:32 - error: Cannot access attribute "shape" for class "Infinity"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:402:32 - error: Cannot access attribute "shape" for class "NegativeInfinity"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:402:32 - error: Cannot access attribute "shape" for class "Float"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:428:25 - error: Cannot access attribute "shape" for class "Infinity"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:428:25 - error: Cannot access attribute "shape" for class "NegativeInfinity"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:428:25 - error: Cannot access attribute "shape" for class "Float"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:438:31 - error: Operator "*" not supported for types "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | One | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | NotImplementedType | Expr | MatMul" and "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | MatrixExpr"
+ .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:438:31 - error: Operator "*" not supported for types "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | One | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Expr | MatMul" and "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | MatrixExpr"
+ .../projects/sympy/sympy/tensor/tensor.py:4366:42 - error: Operator "*" not supported for types "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown" and "Basic | Unknown"
+ Operator "*" not supported for types "ComplexInfinity" and "Basic" when expected type is "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown" (reportOperatorIssue)
- .../projects/sympy/sympy/tensor/tests/test_functions.py:41:17 - error: Cannot access attribute "shape" for class "Infinity"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/tests/test_functions.py:41:17 - error: Cannot access attribute "shape" for class "NegativeInfinity"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/tests/test_functions.py:41:17 - error: Cannot access attribute "shape" for class "Float"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/tests/test_functions.py:41:17 - error: Cannot access attribute "shape" for class "Expr"
- Attribute "shape" is unknown (reportAttributeAccessIssue)
- Attribute "rank" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/tests/test_functions.py:42:17 - error: Cannot access attribute "rank" for class "Infinity"
- Attribute "rank" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/tensor/tests/test_functions.py:42:17 - error: Cannot access attribute "rank" for class "NegativeInfinity"
- Attribute "rank" is unknown (reportAttributeAccessIssue)
... (truncated 540 lines) ...
jax (https://github.com/google/jax)
+ .../projects/jax/jax/_src/pallas/mosaic/sc_lowering.py:785:11 - error: "log_buffer" is not a known attribute of module "jaxlib.mosaic.python.tpu" (reportAttributeAccessIssue)
+ .../projects/jax/jax/_src/pallas/mosaic/sc_lowering.py:787:11 - error: "log" is not a known attribute of module "jaxlib.mosaic.python.tpu" (reportAttributeAccessIssue)
- 3083 errors, 83 warnings, 0 informations
+ 3085 errors, 83 warnings, 0 informations
|
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.
Fix pattern matching regression for variadic tuple types
When a tuple with an unbounded entry (e.g., tuple[int, *tuple[str, ...], int])
is matched against a pattern shorter than the tuple, the unbounded entry is
removed to make lengths match. However, this loses the information that the
tuple was originally variadic and could have different lengths.
The fix tracks when an unbounded entry is removed (removedIndeterminate flag)
and marks such matches as isPotentialNoMatch=true. This prevents the entire
variadic tuple from being eliminated in negative narrowing, preserving
reachability of subsequent match cases.
Fixes #10845