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

double click to insert inlay hints #968

Merged
merged 10 commits into from
Jan 26, 2025
Merged

double click to insert inlay hints #968

merged 10 commits into from
Jan 26, 2025

Conversation

DetachHead
Copy link
Owner

@DetachHead DetachHead commented Dec 25, 2024

fixes #198

@DetachHead DetachHead force-pushed the inlay-hint-stuff branch 3 times, most recently from b53f178 to 9be6034 Compare January 12, 2025 03:35
@DetachHead DetachHead changed the title inlay hint stuff double click to insert inlay hints Jan 12, 2025
@DetachHead DetachHead marked this pull request as ready for review January 12, 2025 03:37

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

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) ...

arviz (https://github.com/arviz-devs/arviz): 5.73x slower (5.7s -> 32.8s in a single noisy sample)

@DetachHead DetachHead merged commit 9f552b9 into main Jan 26, 2025
20 checks passed
@DetachHead DetachHead deleted the inlay-hint-stuff branch January 26, 2025 14:23
@gsiddhant159
Copy link

Hi, I am using basedpyright 1.26 in neovim 10.4
Is there any docs on a public function/ language server setting to allow implementing this in neovim?

@DetachHead
Copy link
Owner Author

i'm not sure whether neovim supports it, i guess you'd have to ask the maintainers of neovim

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.

code action/double click to transition inlay hints to real life
2 participants