-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed bug that results in a spurious error when an assignment express… #9699
Merged
Conversation
This file contains 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
…ion (walrus operator) is used as an argument to a constructor call when the constructor has both a `__new__` and `__init__` with differing bidirectional type inference contexts. This addresses #9659.
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy)
- /tmp/mypy_primer/projects/sympy/sympy/assumptions/tests/test_refine.py:103:56 - error: Argument of type "Unequality | Unknown" cannot be assigned to parameter "assumptions" of type "bool" in function "refine"
+ /tmp/mypy_primer/projects/sympy/sympy/assumptions/tests/test_refine.py:103:56 - error: Argument of type "Unequality | Integer" cannot be assigned to parameter "assumptions" of type "bool" in function "refine"
- Type "Unequality | Unknown" is not assignable to type "bool"
+ Type "Unequality | Integer" is not assignable to type "bool"
- "Unequality" is not assignable to "bool" (reportArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/assumptions/tests/test_refine.py:105:56 - error: Argument of type "Not | Unknown" cannot be assigned to parameter "assumptions" of type "bool" in function "refine"
- Type "Not | Unknown" is not assignable to type "bool"
- "Not" is not assignable to "bool" (reportArgumentType)
+ "Integer" is not assignable to "bool" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/assumptions/tests/test_refine.py:105:56 - error: Argument of type "Not | One | NegativeOne | Zero | Integer" cannot be assigned to parameter "assumptions" of type "bool" in function "refine"
+ Type "Not | One | NegativeOne | Zero | Integer" is not assignable to type "bool"
+ "Integer" is not assignable to "bool" (reportArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/assumptions/tests/test_refine.py:107:56 - error: Argument of type "Unequality | Unknown" cannot be assigned to parameter "assumptions" of type "bool" in function "refine"
+ /tmp/mypy_primer/projects/sympy/sympy/assumptions/tests/test_refine.py:107:56 - error: Argument of type "Unequality | Integer" cannot be assigned to parameter "assumptions" of type "bool" in function "refine"
- Type "Unequality | Unknown" is not assignable to type "bool"
+ Type "Unequality | Integer" is not assignable to type "bool"
- "Unequality" is not assignable to "bool" (reportArgumentType)
+ "Integer" is not assignable to "bool" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/calculus/tests/test_accumulationbounds.py:275:26 - error: Cannot access attribute "rel_op" for class "Integer"
+ Attribute "rel_op" is unknown (reportAttributeAccessIssue)
+ Attribute "rel_op" is unknown (reportAttributeAccessIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/calculus/tests/test_accumulationbounds.py:276:27 - error: Cannot access attribute "rel_op" for class "Integer"
+ /tmp/mypy_primer/projects/sympy/sympy/calculus/tests/test_accumulationbounds.py:280:26 - error: Cannot access attribute "rel_op" for class "Integer"
+ Attribute "rel_op" is unknown (reportAttributeAccessIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/calculus/tests/test_accumulationbounds.py:281:27 - error: Cannot access attribute "rel_op" for class "Integer"
+ Attribute "rel_op" is unknown (reportAttributeAccessIssue)
+ Attribute "rel_op" is unknown (reportAttributeAccessIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/calculus/tests/test_accumulationbounds.py:284:32 - error: Cannot access attribute "rel_op" for class "Integer"
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:41:16 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:42:16 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:48:43 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:49:43 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:71:16 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:72:16 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:90:43 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:91:43 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:117:10 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1039:16 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1039:39 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1040:20 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1040:45 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1042:36 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1043:36 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1044:36 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1046:40 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1047:40 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:1048:40 - error: "__getitem__" method not defined on type "Basic" (reportIndexIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/core/expr.py:272:24 - error: Type "Basic" is not assignable to return type "Expr"
+ "Basic" is not assignable to "Expr" (reportReturnType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/expr.py:274:24 - error: Type "Basic" is not assignable to return type "Expr"
+ "Basic" is not assignable to "Expr" (reportReturnType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/function.py:480:16 - error: Type "Basic" is not assignable to return type "Expr"
+ "Basic" is not assignable to "Expr" (reportReturnType)
- /tmp/mypy_primer/projects/sympy/sympy/core/function.py:1502:33 - error: Argument of type "Unknown | Expr | Relational | Basic | Equality | Unequality | Add" cannot be assigned to parameter "expr" of type "Expr | complex" in function "factor_terms"
+ /tmp/mypy_primer/projects/sympy/sympy/core/function.py:1502:33 - error: Argument of type "Unknown | Expr | Relational | Basic | Equality | Unequality | Integer | Add" cannot be assigned to parameter "expr" of type "Expr | complex" in function "factor_terms"
- Type "Unknown | Expr | Relational | Basic | Equality | Unequality | Add" is not assignable to type "Expr | complex"
+ Type "Unknown | Expr | Relational | Basic | Equality | Unequality | Integer | Add" is not assignable to type "Expr | complex"
+ /tmp/mypy_primer/projects/sympy/sympy/core/function.py:3296:48 - error: Cannot access attribute "upper" for class "type[Relational]"
+ Attribute "upper" is unknown (reportAttributeAccessIssue)
+ /tmp/mypy_primer/projects/sympy/sympy/core/function.py:3296:48 - error: Cannot access attribute "upper" for class "type[BooleanFunction]"
+ Attribute "upper" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/core/numbers.py:3132:14 - error: Type "(Expr, Unknown) -> (_NotImplementedType | StrictGreaterThan | Unknown | Equality | Relational | Unequality)" is not assignable to declared type "(self: Self@Number, other: Unknown) -> Unknown"
+ /tmp/mypy_primer/projects/sympy/sympy/core/numbers.py:3132:14 - error: Type "(Expr, Unknown) -> (_NotImplementedType | StrictGreaterThan | Unknown | Equality | Relational | Unequality | Integer)" is not assignable to declared type "(self: Self@Number, other: Unknown) -> Unknown"
- Type "(Expr, Unknown) -> (_NotImplementedType | StrictGreaterThan | Unknown | Equality | Relational | Unequality)" is not assignable to type "(self: Self@Number, other: Unknown) -> Unknown"
+ Type "(Expr, Unknown) -> (_NotImplementedType | StrictGreaterThan | Unknown | Equality | Relational | Unequality | Integer)" is not assignable to type "(self: Self@Number, other: Unknown) -> Unknown"
- /tmp/mypy_primer/projects/sympy/sympy/core/numbers.py:3133:14 - error: Type "(Expr, Unknown) -> (_NotImplementedType | GreaterThan | Unknown | Equality | Relational | Unequality)" is not assignable to declared type "(self: Self@Number, other: Unknown) -> Unknown"
+ /tmp/mypy_primer/projects/sympy/sympy/core/numbers.py:3133:14 - error: Type "(Expr, Unknown) -> (_NotImplementedType | GreaterThan | Unknown | Equality | Relational | Unequality | Integer)" is not assignable to declared type "(self: Self@Number, other: Unknown) -> Unknown"
- Type "(Expr, Unknown) -> (_NotImplementedType | GreaterThan | Unknown | Equality | Relational | Unequality)" is not assignable to type "(self: Self@Number, other: Unknown) -> Unknown"
+ Type "(Expr, Unknown) -> (_NotImplementedType | GreaterThan | Unknown | Equality | Relational | Unequality | Integer)" is not assignable to type "(self: Self@Number, other: Unknown) -> Unknown"
... (truncated 1819 lines) ...
xarray (https://github.com/pydata/xarray)
+ /tmp/mypy_primer/projects/xarray/xarray/core/combine.py:164:20 - error: No overloads for "__init__" match the provided arguments (reportCallIssue)
- 2469 errors, 91 warnings, 0 informations
+ 2470 errors, 91 warnings, 0 informations
spark (https://github.com/apache/spark)
+ /tmp/mypy_primer/projects/spark/python/pyspark/core/rdd.py:4238:16 - error: Type "RDD[Tuple[K@cogroup, tuple[ResultIterable[Unknown], ...]]]" is not assignable to return type "RDD[Tuple[K@cogroup, Tuple[ResultIterable[V@cogroup], ResultIterable[U@cogroup]]]]"
+ "RDD[Tuple[K@cogroup, tuple[ResultIterable[Unknown], ...]]]" is not assignable to "RDD[Tuple[K@cogroup, Tuple[ResultIterable[V@cogroup], ResultIterable[U@cogroup]]]]"
+ Type parameter "T_co@RDD" is covariant, but "Tuple[K@cogroup, tuple[ResultIterable[Unknown], ...]]" is not a subtype of "Tuple[K@cogroup, Tuple[ResultIterable[V@cogroup], ResultIterable[U@cogroup]]]"
+ "Tuple[K@cogroup, tuple[ResultIterable[Unknown], ...]]" is not assignable to "Tuple[K@cogroup, Tuple[ResultIterable[V@cogroup], ResultIterable[U@cogroup]]]"
+ Tuple entry 2 is incorrect type
+ "tuple[ResultIterable[Unknown], ...]" is not assignable to "Tuple[ResultIterable[V@cogroup], ResultIterable[U@cogroup]]" (reportReturnType)
- 24443 errors, 298 warnings, 0 informations
+ 24444 errors, 298 warnings, 0 informations
|
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.
…ion (walrus operator) is used as an argument to a constructor call when the constructor has both a
__new__
and__init__
with differing bidirectional type inference contexts. This addresses #9659.