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

fix inlay hints incorrectly appearing on pseudo-generic classes #1021

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

DetachHead
Copy link
Owner

fixes #1015

@DetachHead DetachHead merged commit eee367f into main Jan 27, 2025
20 checks passed
@DetachHead DetachHead deleted the fix-inlay-hints-pseudogeneric-class branch January 27, 2025 14:47
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 "constant_renumber" is "(expr: Unknown, variables: Unknown | None = None, newconstants: Unknown | None = None) -> (list[Unknown] | set[Unknown] | tuple[Unknown, ...] | Boolean | Basic | Unknown)" (reportUnknownVariableType)
+     Type of "constant_renumber" is "(expr: Unknown, variables: Unknown | None = None, newconstants: Unknown | None = None) -> (list[Unknown] | set[Unknown] | tuple[Unknown, ...] | Boolean | Expr | Basic | Unknown)" (reportUnknownVariableType)
-     Type of "i" is "Equality | Unknown" (reportUnknownVariableType)
+     Type of "i" is "Equality | Unknown | Relational | Unequality | Integer" (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 "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[Expr | Unknown | Basic] | list[Unknown | Poly | Basic] | list[Min | Max] | list[Unknown | Max | Min] | list[Expr | Unknown] | list[Unknown | Poly])" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_decompogen.py:23:31 - warning: Return type of lambda, "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]", is partially unknown (reportUnknownLambdaType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_decompogen.py:23:31 - warning: Return type of lambda, "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[Expr | Unknown | Basic] | list[Unknown | Poly | Basic] | list[Min | Max] | list[Unknown | Max | Min] | list[Expr | Unknown] | list[Unknown | Poly]", is partially unknown (reportUnknownLambdaType)
-     Type of "rootof" is "(f: Unknown, x: Unknown, index: Unknown | None = None, radicals: bool = True, expand: bool = True) -> (Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType | Expr)" (reportUnknownVariableType)
+     Type of "rootof" is "(f: Unknown, x: Unknown, index: Unknown | None = None, radicals: bool = True, expand: bool = True) -> (Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Expr)" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:134:9 - warning: Type of "inf" is partially unknown
+     Type of "inf" is "One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:137:16 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "args" in function "__new__"
-     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:137:16 - error: Argument of type "Equality | Unknown | Relational | Unequality | Integer" cannot be assigned to parameter "args" of type "Boolean | bool" in function "__new__"
+     Type "Equality | Unknown | Relational | Unequality | Integer" is not assignable to type "Boolean | bool"
+       Type "Integer" is not assignable to type "Boolean | bool"
+         "Integer" is not assignable to "Boolean"
+         "Integer" is not assignable to "bool" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:137:29 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "args" in function "__new__"
-     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:137:29 - error: Argument of type "Equality | Unknown | Relational | Unequality | Integer" cannot be assigned to parameter "args" of type "Boolean | bool" in function "__new__"
+     Type "Equality | Unknown | Relational | Unequality | Integer" is not assignable to type "Boolean | bool"
+       Type "Integer" is not assignable to type "Boolean | bool"
+         "Integer" is not assignable to "Boolean"
+         "Integer" is not assignable to "bool" (reportArgumentType)
-     Type of "e" is "Equality | Unknown | NaN | Sum" (reportUnknownVariableType)
+     Type of "e" is "Equality | Unknown | Relational | Unequality | Integer | NaN | Sum" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:287:12 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "args" in function "__new__"
-     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:287:12 - error: Argument of type "Equality | Unknown | Relational | Unequality | Integer" cannot be assigned to parameter "args" of type "Boolean | bool" in function "__new__"
+     Type "Equality | Unknown | Relational | Unequality | Integer" is not assignable to type "Boolean | bool"
+       Type "Integer" is not assignable to type "Boolean | bool"
+         "Integer" is not assignable to "Boolean"
+         "Integer" is not assignable to "bool" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:287:22 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "args" in function "__new__"
-     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:287:22 - error: Argument of type "Equality | Unknown | Relational | Unequality | Integer" cannot be assigned to parameter "args" of type "Boolean | bool" in function "__new__"
+     Type "Equality | Unknown | Relational | Unequality | Integer" is not assignable to type "Boolean | bool"
+       Type "Integer" is not assignable to type "Boolean | bool"
+         "Integer" is not assignable to "Boolean"
+         "Integer" is not assignable to "bool" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:297:79 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "args" in function "__new__"
-     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:297:79 - error: Argument of type "Equality | Unknown | Relational | Unequality | Integer" cannot be assigned to parameter "args" of type "Boolean | bool" in function "__new__"
+     Type "Equality | Unknown | Relational | Unequality | Integer" is not assignable to type "Boolean | bool"
+       Type "Integer" is not assignable to type "Boolean | bool"
+         "Integer" is not assignable to "Boolean"
+         "Integer" is not assignable to "bool" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:297:89 - warning: Argument type is partially unknown
-     Argument corresponds to parameter "args" in function "__new__"
-     Argument type is "Equality | Unknown" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:297:89 - error: Argument of type "Equality | Unknown | Relational | Unequality | Integer" cannot be assigned to parameter "args" of type "Boolean | bool" in function "__new__"
+     Type "Equality | Unknown | Relational | Unequality | Integer" is not assignable to type "Boolean | bool"
+       Type "Integer" is not assignable to type "Boolean | bool"
+         "Integer" is not assignable to "Boolean"
+         "Integer" is not assignable to "bool" (reportArgumentType)
-     Type of "r" is "Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType | Expr" (reportUnknownVariableType)
+     Type of "r" is "Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Expr" (reportUnknownVariableType)
-     Type of "ie" is "Equality | Unknown" (reportUnknownVariableType)
+     Type of "ie" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_inequalities.py:459:13 - warning: Type of "e" is partially unknown
+     Type of "e" is "Any | _NotImplementedType | StrictGreaterThan | Unknown | Equality | Relational | Unequality | Integer" (reportUnknownVariableType)
-     Type of "e" is "Equality | Unknown" (reportUnknownVariableType)
+     Type of "e" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)
-     Type of "eq" is "Equality | Unknown" (reportUnknownVariableType)
+     Type of "eq" is "Equality | Unknown | Relational | Unequality | Integer" (reportUnknownVariableType)

... (truncated 5115 lines) ...

comtypes (https://github.com/enthought/comtypes): 246.79x slower (0.1s -> 25.4s in a single noisy sample)

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.

generic inlay hints should not appear on pseudo-generic classes
1 participant