Skip to content

Changed behavior when @final is applied to a method but subsequent …#10578

Merged
erictraut merged 1 commit intomainfrom
issue-10543
Jun 10, 2025
Merged

Changed behavior when @final is applied to a method but subsequent …#10578
erictraut merged 1 commit intomainfrom
issue-10543

Conversation

@erictraut
Copy link
Collaborator

…decorators (like @functools.cache or @property) subsequently transform the method into a different type. The typing spec is not clear how this should work. Pyright now honors the @final in these cases, which is consistent with mypy. This addresses #10543.

…decorators (like `@functools.cache` or `@property`) subsequently transform the method into a different type. The typing spec is not clear how this should work. Pyright now honors the `@final` in these cases, which is consistent with mypy. This addresses #10543.
@github-actions
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:340:64 - error: Operator "-" not supported for types "Literal[1]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:340:64 - error: Operator "-" not supported for types "Literal[1]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:341:63 - error: Operator "-" not supported for types "Literal[1]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:341:63 - error: Operator "-" not supported for types "Literal[1]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:342:63 - error: Operator "-" not supported for types "Literal[1]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:342:63 - error: Operator "-" not supported for types "Literal[1]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:436:72 - error: Operator "-" not supported for types "Literal[1]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:436:72 - error: Operator "-" not supported for types "Literal[1]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:437:72 - error: Operator "-" not supported for types "Literal[1]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:437:72 - error: Operator "-" not supported for types "Literal[1]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:438:71 - error: Operator "-" not supported for types "Literal[1]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:438:71 - error: Operator "-" not supported for types "Literal[1]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:565:45 - 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 "Literal[4]"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:565:45 - 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 | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None" and "Literal[4]"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:582: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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:582: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 | Sum | 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 | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:641:37 - error: Operator "*" not supported for types "Literal[3]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:641:37 - error: Operator "*" not supported for types "Literal[3]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"
-   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:641:37 - error: Operator "+" not supported for types "Unknown | Any | Expr | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | int | tuple[Unknown, ...]" 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"
+   .../projects/sympy/sympy/stats/tests/test_stochastic_process.py:641:37 - error: Operator "+" not supported for types "Unknown | Any | Expr | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | int | tuple[Unknown, ...]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | _NotImplementedType | tuple[Unknown, ...] | Sum* | Piecewise | Basic | Sum | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0] | None"

... (truncated 495 lines) ...

@erictraut erictraut merged commit 8610325 into main Jun 10, 2025
17 checks passed
@erictraut erictraut deleted the issue-10543 branch June 10, 2025 01:57
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.

1 participant