Fixed longstanding bug in tokenizer that can result in incorrect beha…#10504
Merged
Fixed longstanding bug in tokenizer that can result in incorrect beha…#10504
Conversation
…vior under certain circumstances involving characters that require two uint16 unicode character codes (a surrogate followed by a second word).
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy)
- ...:40:12 - error: Operator "-" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Unknown | Expr | Any | int"
+ ...:40:12 - error: Operator "-" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Unknown | Expr | int"
- ...:40:37 - error: Operator "**" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Literal[2]"
+ ...:40:37 - error: Operator "**" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Literal[2]"
- ...:84:12 - error: Operator "-" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Unknown | Expr | Any | int"
+ ...:84:12 - error: Operator "-" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Unknown | Expr | int"
- ...:84:37 - error: Operator "**" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Literal[2]"
+ ...:84:37 - error: Operator "**" not supported for types "Unknown | tuple[Unknown, ...] | Sum | Zero | NaN | Piecewise | Basic | Literal[0] | None" and "Literal[2]"
- ...:137:33 - error: Operator "+" not supported for types "Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None" and "Expr | Unknown | tuple[Unknown, ...] | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | MatMul | int"
+ ...:137:33 - error: Operator "+" not supported for types "Expr | Basic | Expectation | tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Integral | Any | ExpectationMatrix | Literal[0] | None" and "Expr | Unknown | tuple[Unknown, ...] | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Any | MatMul | int"
- ...:137:43 - error: Operator "*" not supported for types "Literal[2]" and "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None"
+ ...:137:43 - error: Operator "*" not supported for types "Literal[2]" and "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Integral | Any | ExpectationMatrix | Literal[0] | None"
- ...:163:21 - error: Argument of type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
+ ...:163:21 - error: Argument of type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Integral | Any | ExpectationMatrix | Literal[0] | None" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None" is not assignable to type "Basic"
+ Type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Integral | Any | ExpectationMatrix | Literal[0] | None" is not assignable to type "Basic"
- ...:33:23 - error: Operator "/" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None"
+ ...:33:23 - error: Operator "/" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
- ...:34:23 - error: Operator "*" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None"
+ ...:34:23 - error: Operator "*" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
- ...:34:23 - error: Operator "/" not supported for types "Unknown | Any | Expr | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | tuple[Unknown, ...] | Infinity | NegativeInfinity | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None"
+ ...:34:23 - error: Operator "/" not supported for types "Unknown | Any | Expr | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | _NotImplementedType | tuple[Unknown, ...] | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
- ...:293:21 - error: Argument of type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
+ ...:293:21 - error: Argument of type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Integral | Any | ExpectationMatrix | Literal[0] | None" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None" is not assignable to type "Basic"
+ Type "RandomSymbol | Basic | Expectation | Expr | tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Integral | Any | ExpectationMatrix | Literal[0] | None" is not assignable to type "Basic"
- ...:467:12 - error: Operator "+" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0] | None"
+ ...:467:12 - error: Operator "+" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
- ...:299:21 - error: Argument of type "Unknown | Tuple | Indexed | Basic | Expectation | Expr | tuple[Unknown, ...] | Sum | Any | Zero | NaN | Piecewise | Integral | ExpectationMatrix | Literal[0] | None" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
... (truncated 1595 lines) ...
|
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.
…vior under certain circumstances involving characters that require two uint16 unicode character codes (a surrogate followed by a second word).