Skip to content
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

don't report reportUnnecessaryComparison when using assert_never in an intentionally unreachable case in a match statement #593

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

DetachHead
Copy link
Owner

fixes #469

… in an intentionally unreachable case in a match statement
@DetachHead DetachHead changed the title don't report reportUnnecessaryComparison whern using assert_never in an intentionally unreachable case in a match statement don't report reportUnnecessaryComparison when using assert_never in an intentionally unreachable case in a match statement Aug 19, 2024
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sympy (https://github.com/sympy/sympy)
-     Type of "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None)" (reportUnknownVariableType)
+     Type of "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None)" (reportUnknownVariableType)
-     Type of "E" is "(expr: Unknown, condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Basic | Expectation | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "E" is "(expr: Unknown, condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Basic | Expectation | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
-     Type of "covariance" is "(X: Unknown, Y: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (CrossCovarianceMatrix | Covariance | Unknown | Basic | Expectation | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "covariance" is "(X: Unknown, Y: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (CrossCovarianceMatrix | Covariance | Unknown | Basic | Expectation | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:33:23 - error: Operator "/" not supported for types "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None" and "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:33:23 - error: Operator "/" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None" and "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None"
+     Operator "/" not supported for types "BernoulliDistribution" and "Expr*"
-     Operator "/" not supported for types "BernoulliDistribution" and "Basic"
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:34:23 - error: Operator "*" not supported for types "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None" and "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:34:23 - error: Operator "*" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None" and "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None"
+     Operator "*" not supported for types "BernoulliDistribution" and "Expr*"
-     Operator "*" not supported for types "BernoulliDistribution" and "Basic"
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:34:23 - error: Operator "/" not supported for types "Unknown | Any | tuple[Unknown, ...] | int" and "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:34:23 - error: Operator "/" not supported for types "Unknown | Any | tuple[Unknown, ...] | int" and "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None"
+     Operator "/" not supported for types "tuple[Unknown, ...]" and "Expr*"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "Basic"
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:181:32 - error: Return type of lambda, "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None", is partially unknown (reportUnknownLambdaType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:181:32 - error: Return type of lambda, "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None", is partially unknown (reportUnknownLambdaType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:253:32 - error: Return type of lambda, "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None", is partially unknown (reportUnknownLambdaType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:253:32 - error: Return type of lambda, "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None", is partially unknown (reportUnknownLambdaType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:308:41 - error: Return type of lambda, "Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None", is partially unknown (reportUnknownLambdaType)
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_finite_rv.py:308:41 - error: Return type of lambda, "Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None", is partially unknown (reportUnknownLambdaType)
-     Type of "expand" is "((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | RandomSymbol)) | Unknown | ((**hints: Unknown) -> (Basic | Add | Unknown | GenericIdentity* | Order | Expectation)) | ((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | Sum)) | ((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any)) | Any | ((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | Piecewise)) | ((**kwargs: Unknown) -> Equality) | ((**kwargs: Unknown) -> Relational) | ((**kwargs: Unknown) -> Unequality) | ((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | Integral)) | ((**hints: Unknown) -> (Basic | Add | ExpectationMatrix | Unknown | GenericIdentity* | Order))" (reportUnknownMemberType)

... (truncated 1190 lines) ...

mitmproxy (https://github.com/mitmproxy/mitmproxy)
-   /tmp/mypy_primer/projects/mitmproxy/mitmproxy/addons/next_layer.py:339:18 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
-   /tmp/mypy_primer/projects/mitmproxy/mitmproxy/addons/next_layer.py:398:18 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
-   /tmp/mypy_primer/projects/mitmproxy/mitmproxy/proxy/layers/modes.py:81:18 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
- 32701 errors, 0 warnings, 0 notes
+ 32698 errors, 0 warnings, 0 notes

@DetachHead DetachHead merged commit baf1a1e into main Aug 19, 2024
19 checks passed
@DetachHead DetachHead deleted the reportUnnecessaryComparison-fix branch August 19, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert_never with Union type and match ... case triggers reportUnnecessaryComparison
2 participants