Fixed bug that results in a false positive error when a with statem…#11024
Merged
Fixed bug that results in a false positive error when a with statem…#11024
with statem…#11024Conversation
…ent has a single parenthesized context manager. This addresses #11020.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: scrapy (https://github.com/scrapy/scrapy)
- .../projects/scrapy/tests/test_pipelines.py:468:14 - error: Object of type "tuple[Unknown]" cannot be used with "with" because it does not correctly implement __enter__
- Attribute "__enter__" is unknown (reportGeneralTypeIssues)
- .../projects/scrapy/tests/test_pipelines.py:468:14 - error: Object of type "tuple[Unknown]" cannot be used with "with" because it does not correctly implement __exit__
- Attribute "__exit__" is unknown (reportGeneralTypeIssues)
- 2025 errors, 125 warnings, 0 informations
+ 2023 errors, 125 warnings, 0 informations
sympy (https://github.com/sympy/sympy)
+ .../projects/sympy/sympy/solvers/diophantine/diophantine.py:173:44 - error: Cannot access attribute "expand" for class "Basic"
+ Attribute "expand" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/solvers/diophantine/diophantine.py:528:23 - error: Operator "+" not supported for types "Generator[Unknown | int, Unknown, None] | list[Unknown | int]" and "list[Unknown | int]"
+ .../projects/sympy/sympy/solvers/diophantine/diophantine.py:528:23 - error: Operator "+" not supported for types "Generator[Unknown | Literal[1], Unknown, None] | list[Unknown | Literal[1]]" and "list[Unknown | int]"
- Operator "+" not supported for types "Generator[Unknown | int, Unknown, None]" and "list[Unknown | int]" (reportOperatorIssue)
+ Operator "+" not supported for types "Generator[Unknown | Literal[1], Unknown, None]" and "list[Unknown | int]" (reportOperatorIssue)
+ .../projects/sympy/sympy/solvers/ode/lie_group.py:618:61 - error: Operator "-" not supported for type "Basic | Unknown" (reportOperatorIssue)
- .../projects/sympy/sympy/solvers/ode/single.py:865:9 - error: Expression with type "tuple[ComplexInfinity | Unknown | Any, list[tuple[Unknown, Unknown]] | list[Unknown]] | tuple[ComplexInfinity | Unknown | Any, list[tuple[Unknown, Unknown]] | list[Unknown], list[tuple[Unknown, Unknown]] | list[Unknown]]" cannot be assigned to target tuple
- Type "tuple[ComplexInfinity | Unknown | Any, list[tuple[Unknown, Unknown]] | list[Unknown], list[tuple[Unknown, Unknown]] | list[Unknown]]" is incompatible with target tuple
- Tuple size mismatch; expected 2 but received 3 (reportAssignmentType)
+ .../projects/sympy/sympy/solvers/ode/single.py:2636: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 | Infinity | NegativeInfinity | Float | Number | Expr" is not assignable to type "SupportsIndex"
+ "Expr" is incompatible with protocol "SupportsIndex"
+ "__index__" is not present (reportArgumentType)
- .../projects/sympy/sympy/solvers/solveset.py:775:18 - error: Argument of type "Unknown | None" cannot be assigned to parameter "expr" of type "Expr" in function "together"
+ .../projects/sympy/sympy/solvers/solveset.py:775:18 - error: Argument of type "Unknown | Expr | Any | None" cannot be assigned to parameter "expr" of type "Expr" in function "together"
- Type "Unknown | None" is not assignable to type "Expr"
+ Type "Unknown | Expr | Any | None" is not assignable to type "Expr"
- .../projects/sympy/sympy/solvers/solveset.py:1324:21 - error: Argument of type "One | Expr | Relational | Basic | NegativeOne | Zero | Integer | ComplexInfinity | NaN | Rational | Unknown | Add" cannot be assigned to parameter "args" of type "Expr | complex" in function "__new__"
- Type "One | Expr | Relational | Basic | NegativeOne | Zero | Integer | ComplexInfinity | NaN | Rational | Unknown | Add" is not assignable to type "Expr | complex"
- Type "Basic" is not assignable to type "Expr | complex"
- "Basic" is not assignable to "Expr"
- "Basic" is not assignable to "complex" (reportArgumentType)
- .../projects/sympy/sympy/stats/crv_types.py:2542:9 - error: Method "_cdf" overrides class "SingleContinuousDistribution" in an incompatible manner
- Return type mismatch: base method returns type "None", override returns type "ComplexInfinity | Unknown"
- Type "ComplexInfinity | Unknown" is not assignable to type "None"
- "ComplexInfinity" is not assignable to "None" (reportIncompatibleMethodOverride)
- .../projects/sympy/sympy/stats/crv_types.py:2721:9 - error: Method "_cdf" overrides class "SingleContinuousDistribution" in an incompatible manner
- Return type mismatch: base method returns type "None", override returns type "Expr | Unknown"
- Type "Expr | Unknown" is not assignable to type "None"
- "Expr" is not assignable to "None" (reportIncompatibleMethodOverride)
- .../projects/sympy/sympy/stats/symbolic_probability.py:74:9 - error: Method "doit" overrides class "Basic" in an incompatible manner
- Return type mismatch: base method returns type "Basic", override returns type "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"
- Type "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" is not assignable to type "Basic"
- "Literal[0]" is not assignable to "Basic" (reportIncompatibleMethodOverride)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1542:12 - error: No overloads for "simplify" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1542:21 - error: Argument of type "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" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "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" is not assignable to type "Basic"
- "Literal[0]" is not assignable to "Basic" (reportArgumentType)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1544:12 - error: No overloads for "simplify" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1544:21 - error: Argument of type "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" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "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" is not assignable to type "Basic"
- "Literal[0]" is not assignable to "Basic" (reportArgumentType)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1549:12 - error: No overloads for "simplify" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1549:21 - error: Argument of type "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" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "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" is not assignable to type "Basic"
- "Literal[0]" is not assignable to "Basic" (reportArgumentType)
- .../projects/sympy/sympy/stats/tests/test_finite_rv.py: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"
+ .../projects/sympy/sympy/stats/tests/test_finite_rv.py: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"
... (truncated 1148 lines) ...
zulip (https://github.com/zulip/zulip)
- .../projects/zulip/corporate/tests/test_stripe.py:2364:14 - error: Object of type "tuple[_patch_pass_arg[MagicMock | AsyncMock]]" cannot be used with "with" because it does not correctly implement __enter__
- Attribute "__enter__" is unknown (reportGeneralTypeIssues)
- .../projects/zulip/corporate/tests/test_stripe.py:2364:14 - error: Object of type "tuple[_patch_pass_arg[MagicMock | AsyncMock]]" cannot be used with "with" because it does not correctly implement __exit__
- Attribute "__exit__" is unknown (reportGeneralTypeIssues)
- .../projects/zulip/zerver/tests/test_auth_backends.py:3704:14 - error: Object of type "tuple[Any]" cannot be used with "with" because it does not correctly implement __enter__
- Attribute "__enter__" is unknown (reportGeneralTypeIssues)
- .../projects/zulip/zerver/tests/test_auth_backends.py:3704:14 - error: Object of type "tuple[Any]" cannot be used with "with" because it does not correctly implement __exit__
- Attribute "__exit__" is unknown (reportGeneralTypeIssues)
- .../projects/zulip/zerver/tests/test_auth_backends.py:8431:14 - error: Object of type "tuple[Any]" cannot be used with "with" because it does not correctly implement __enter__
- Attribute "__enter__" is unknown (reportGeneralTypeIssues)
- .../projects/zulip/zerver/tests/test_auth_backends.py:8431:14 - error: Object of type "tuple[Any]" cannot be used with "with" because it does not correctly implement __exit__
- Attribute "__exit__" is unknown (reportGeneralTypeIssues)
- 5014 errors, 344 warnings, 0 informations
+ 5008 errors, 344 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.
…ent has a single parenthesized context manager. This addresses #11020.