microsoft / pyright

Static Type Checker for Python
Other
13.21k stars 1.42k forks source link

Changed the hard-coded type of the `__class__` symbol to be `Self@T` … #8307

Closed erictraut closed 3 months ago

erictraut commented 3 months ago

…rather than T (where T is the enclosing class). This addresses #8305.

github-actions[bot] commented 3 months ago

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/functions/elementary/complexes.py:437:20 - error: Operator "*" not supported for types "Heaviside" and "Literal[2]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/complexes.py:437:20 - error: Operator "*" not supported for types "type[__class_UndefinedFunction] | Unknown" and "Literal[2]"
+     Operator "*" not supported for types "type[__class_UndefinedFunction]" and "Literal[2]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/complexes.py:681:24 - error: Operator "-" not supported for types "Heaviside" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/complexes.py:681:24 - error: Operator "-" not supported for types "type[__class_UndefinedFunction] | Unknown" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "-" not supported for types "type[__class_UndefinedFunction]" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_complexes.py:318:42 - error: Operator "*" not supported for types "Literal[2]" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_complexes.py:318:42 - error: Operator "*" not supported for types "Literal[2]" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Literal[2]" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_complexes.py:489:17 - error: Operator "*" not supported for types "Symbol" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_complexes.py:489:17 - error: Operator "*" not supported for types "Symbol" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Symbol" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_complexes.py:489:34 - error: Operator "*" not supported for types "Symbol" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_complexes.py:489:34 - error: Operator "*" not supported for types "Symbol" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Symbol" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:112:43 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Unknown" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:113:11 - error: Operator "*" not supported for types "Literal[2]" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:113:11 - error: Operator "*" not supported for types "Literal[2]" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Literal[2]" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:357:9 - error: Operator "*" not supported for types "Literal[3]" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:357:9 - error: Operator "*" not supported for types "Literal[3]" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Literal[3]" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:364:9 - error: Operator "*" not supported for types "Literal[3]" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:364:9 - error: Operator "*" not supported for types "Literal[3]" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Literal[3]" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:368:11 - error: Operator "*" not supported for types "Literal[2]" and "Heaviside" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/tests/test_miscellaneous.py:368:11 - error: Operator "*" not supported for types "Literal[2]" and "type[__class_UndefinedFunction] | Unknown"
+     Operator "*" not supported for types "Literal[2]" and "type[__class_UndefinedFunction]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:99:15 - error: Cannot access attribute "args" for class "type[__class_UndefinedFunction]"
+     Attribute "args" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:99:26 - error: Cannot access attribute "pargs" for class "type[__class_UndefinedFunction]"
+     Attribute "pargs" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:100:15 - error: Cannot access attribute "args" for class "type[__class_UndefinedFunction]"
+     Attribute "args" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:100:26 - error: Cannot access attribute "pargs" for class "type[__class_UndefinedFunction]"
+     Attribute "pargs" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:101:16 - error: Cannot access attribute "args" for class "type[__class_UndefinedFunction]"
+     Attribute "args" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:102:16 - error: Cannot access attribute "pargs" for class "type[__class_UndefinedFunction]"
+     Attribute "pargs" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:111:25 - error: Cannot access attribute "diff" for class "type[__class_UndefinedFunction]"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:112:29 - error: Cannot access attribute "is_Function" for class "type[__class_UndefinedFunction]"
+     Attribute "is_Function" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:113:27 - error: Cannot access attribute "is_Function" for class "type[__class_UndefinedFunction]"
+     Attribute "is_Function" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:115:53 - error: Cannot access attribute "fdiff" for class "type[__class_UndefinedFunction]"
+     Attribute "fdiff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:122:25 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:124:25 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:126:28 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:128:28 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:130:28 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:132:30 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:135:25 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:136:39 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:143:25 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:144:33 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"
+     Attribute "rewrite" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/functions/special/tests/test_delta_functions.py:145:28 - error: Cannot access attribute "rewrite" for class "type[__class_UndefinedFunction]"

... (truncated 300 lines) ...