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 add @override decorator on method completions if targeting python <3.12 unless basedpyright.analysis.useTypingExtensions is enabled #1099

Merged
merged 2 commits into from
Feb 23, 2025

Conversation

DetachHead
Copy link
Owner

fixes #1097

…thon <3.12 unless typing-extensions is installed

This comment has been minimized.

@DetachHead DetachHead force-pushed the typing_extensions-override-fix branch from dcb5cb9 to 117acdf Compare February 23, 2025 12:33
@DetachHead DetachHead changed the title don't add @override decorator on method completions if targeting python <3.12 unless typing-extensions is installed don't add @override decorator on method completions if targeting python <3.12 unless basedpyright.analysis.useTypingExtensions is enabled Feb 23, 2025
… don't accidentally make their project depend on `typing_extensions`
@DetachHead DetachHead force-pushed the typing_extensions-override-fix branch from 117acdf to 1481187 Compare February 23, 2025 13:03
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 "decompogen" is "(f: Unknown, symbol: Unknown) -> (list[Expr] | list[Function | Pow] | list[Expr | Basic] | list[Function | Pow | Basic] | Unknown | list[Min | Max | Basic] | list[Unknown | Max | Min | Basic] | list[Basic] | list[Min | Max] | list[Unknown | Max | Min] | list[Unknown])" (reportUnknownVariableType)
+     Type of "decompogen" is "(f: Unknown, symbol: Unknown) -> (list[Expr] | list[Function | Pow] | list[Expr | Basic] | list[Function | Pow | Basic] | Unknown | list[Min | Max | Basic] | list[Unknown | Max | Min | Basic] | list[Basic] | list[Unknown | Poly | Basic] | list[Min | Max] | list[Unknown | Max | Min] | list[Unknown] | list[Unknown | Poly])" (reportUnknownVariableType)
-     Type of "factor" is "(f: Unknown, ..., deep: bool = False) -> (Unknown | Expr)" (reportUnknownVariableType)
+     Type of "factor" is "(f: Unknown, ..., deep: bool = False) -> (Unknown | Add | Expr | Mul)" (reportUnknownVariableType)
-     Type of "eq" is "Unknown | None" (reportUnknownVariableType)
+     Type of "eq" is "Unknown | Expr | Any | Integer | None" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:128:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "expr" in function "_mexpand" (reportUnknownArgumentType)
-     Type of "mainlog" is "Unknown | None" (reportUnknownVariableType)
+     Type of "mainlog" is "log | Any | Unknown | None" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:132:5 - warning: Type of "other" is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:132:5 - warning: Type of "other" is partially unknown
+     Type of "other" is "Expr | Any | Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:132:13 - warning: Type of "subs" is unknown (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:132:13 - warning: Type of "subs" is partially unknown
+     Type of "subs" is "Unknown | Overload[(arg1: Mapping[Basic | complex, Expr | complex], arg2: None = None) -> Expr, (arg1: Iterable[tuple[Basic | complex, Expr | complex]], arg2: None = None, **kwargs: Any) -> Expr, (arg1: Expr | complex, arg2: Expr | complex) -> Expr, (arg1: Mapping[Basic | complex, Basic | complex], arg2: None = None, **kwargs: Any) -> Basic, (arg1: Iterable[tuple[Basic | complex, Basic | complex]], arg2: None = None, **kwargs: Any) -> Basic, (arg1: Basic | complex, arg2: Basic | complex, **kwargs: Any) -> Basic] | Any" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:132:21 - warning: Argument type is partially unknown
+     Argument corresponds to parameter "arg1" in function "subs"
+     Argument type is "log | Any | Unknown" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:134:9 - warning: Type of "eq" is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:134:9 - warning: Type of "eq" is partially unknown
+     Type of "eq" is "Expr | Any | Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:134:14 - warning: Type of "subs" is unknown (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:134:14 - warning: Type of "subs" is partially unknown
+     Type of "subs" is "Overload[(arg1: Mapping[Basic | complex, Expr | complex], arg2: None = None) -> Expr, (arg1: Iterable[tuple[Basic | complex, Expr | complex]], arg2: None = None, **kwargs: Any) -> Expr, (arg1: Expr | complex, arg2: Expr | complex) -> Expr, (arg1: Mapping[Basic | complex, Basic | complex], arg2: None = None, **kwargs: Any) -> Basic, (arg1: Iterable[tuple[Basic | complex, Basic | complex]], arg2: None = None, **kwargs: Any) -> Basic, (arg1: Basic | complex, arg2: Basic | complex, **kwargs: Any) -> Basic] | Any | Unknown" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:134:32 - warning: Argument type is partially unknown
+     Argument corresponds to parameter "arg1" in function "subs"
+     Argument type is "log | Any | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:134:41 - warning: Argument type is partially unknown
+     Argument corresponds to parameter "arg2" in function "subs"
+     Argument type is "Expr | Any | Unknown" (reportUnknownArgumentType)
-     Type of "args" is "Unknown" (reportUnknownMemberType)
+     Type of "args" is "Tuple[Expr] | Any | Unknown" (reportUnknownMemberType)
-     Type of "mainlog" is "Unknown" (reportUnknownVariableType)
+     Type of "mainlog" is "Expr | Any | Unknown" (reportUnknownVariableType)
-     Type of "args" is "Unknown" (reportUnknownMemberType)
+     Type of "args" is "Tuple[Expr] | Any | Unknown" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:138:17 - error: Operator "-" not supported for type "Basic | Any | Unknown" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:138:18 - warning: Type of "args" is unknown (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:138:18 - warning: Type of "args" is partially unknown
+     Type of "args" is "tuple[Basic, ...] | Any | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:139:9 - warning: Type of "eq" is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:139:9 - warning: Type of "eq" is partially unknown
+     Type of "eq" is "Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:140:17 - warning: Type of "free_symbols" is unknown (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:140:17 - warning: Type of "free_symbols" is partially unknown
+     Type of "free_symbols" is "Unknown | set[Basic] | Any" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:142:23 - warning: Argument type is unknown
-     Argument corresponds to parameter "arg" in function "_linab" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:143:23 - warning: Argument type is unknown
-     Argument corresponds to parameter "expr" in function "collect" (reportUnknownArgumentType)
-     Type of "logarg" is "Expr | Unknown" (reportUnknownVariableType)
+     Type of "logarg" is "Expr | Any | Unknown" (reportUnknownVariableType)
-     Type of "args" is "Tuple[Expr] | Unknown" (reportUnknownMemberType)
+     Type of "args" is "Tuple[Expr] | Any | Unknown" (reportUnknownMemberType)
-     Type of "eq" is "Unknown | Expr | Any | Self@Expr" (reportUnknownVariableType)
+     Type of "eq" is "Unknown | Expr | Any" (reportUnknownVariableType)
-     Type of "lhs" is "Unknown | Expr | Any | Self@Expr" (reportUnknownVariableType)
+     Type of "lhs" is "Unknown | Expr | Any" (reportUnknownVariableType)
-     Type of "lhs" is "Unknown | Expr | Self@Expr | Any" (reportUnknownVariableType)
+     Type of "lhs" is "Unknown | Expr | Any" (reportUnknownVariableType)
-     Type of "xreplace" is "Unknown | ((rule: Unknown) -> (Unknown | Expr)) | Any | ((rule: Unknown) -> (Unknown | Self@Expr))" (reportUnknownMemberType)
+     Type of "xreplace" is "Unknown | ((rule: Unknown) -> (Unknown | Expr)) | Any" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:460:9 - warning: Type of "f" is partially unknown
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:460:9 - warning: Type of "f" is unknown (reportUnknownVariableType)
-     Type of "f" is "Unknown | Expr" (reportUnknownVariableType)
-     Type of "as_expr" is "(*gens: Unknown) -> (Unknown | Expr)" (reportUnknownMemberType)
+     Type of "as_expr" is "(*gens: Unknown) -> Unknown" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:463:34 - warning: Type of "subs" is unknown (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:463:34 - warning: Type of "subs" is partially unknown
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:463:34 - warning: Argument type is unknown
-     Type of "subs" is "Unknown | Overload[(arg1: Mapping[Basic | complex, Expr | complex], arg2: None = None) -> Expr, (arg1: Iterable[tuple[Basic | complex, Expr | complex]], arg2: None = None, **kwargs: Any) -> Expr, (arg1: Expr | complex, arg2: Expr | complex) -> Expr, (arg1: Mapping[Basic | complex, Basic | complex], arg2: None = None, **kwargs: Any) -> Basic, (arg1: Iterable[tuple[Basic | complex, Basic | complex]], arg2: None = None, **kwargs: Any) -> Basic, (arg1: Basic | complex, arg2: Basic | complex, **kwargs: Any) -> Basic]" (reportUnknownMemberType)
+     Argument corresponds to parameter "rep" in function "__new__" (reportUnknownArgumentType)
-     Type of "a" is "Unknown | None" (reportUnknownVariableType)
+     Type of "a" is "Unknown | Expr | Any | Self@Expr | Self@Add | None" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:477:9 - warning: Type of "free" is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:477:9 - warning: Type of "free" is partially unknown
+     Type of "free" is "Unknown | set[Basic] | Any" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:477:16 - warning: Type of "free_symbols" is unknown (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/bivariate.py:477:16 - warning: Type of "free_symbols" is partially unknown
-     Type of "decompose" is "(f: Unknown, ...) -> (list[Unknown] | Unknown)" (reportUnknownVariableType)

... (truncated 4594 lines) ...

jinja (https://github.com/pallets/jinja)

pywin32 (https://github.com/mhammond/pywin32)

@DetachHead DetachHead merged commit 9d9de89 into main Feb 23, 2025
20 checks passed
@DetachHead DetachHead deleted the typing_extensions-override-fix branch February 23, 2025 23:51
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.

Provide mechanism to disable automatic @override decorator
1 participant