ITADN

inlay hints for constructor arguments incorrectly displayed when `__init__` signature with positional or keyword arguments and `__new__` with overloads that make the arguments positional only

#1772OpenDetachHead 创建于 2026-04-08
language serverLSP: inlay hints
D
DetachHeadcommented
Code sample in [basedpyright playground](https://basedpyright.com/?typeCheckingMode=all&code=GYJw9gtgBALgngBwJYDsDmUkQWEMoDKApgDbAA0UYAbkSCWAIYAmAsAFAcDGJjAznygAxMGABcHKFKgABGnQYtJ05kWBQA%2BhpREA7loAUPPuUZjMKGJQD0ASigBaAHyFSwcwDovHZVLm16JjZ2aShVdS0dfQ0jEhMzKD4YEBt7Z1cyT29OEJU1TW09Q2NyakYSAFcicySQKAAfCxg0l2JMqC8PH1ypcILUJBhDPjdKMsrqxOSGppaoADkwHQke0KgEfj5ujSgAXmFRAwBGewBiKAADcardi4teOCgAC1R8JEFUcaRmIA) ```python from typing import Self, overload class Foo: @overload def __new__(cls,a: int, /) -> Self: ... @overload def __new__(cls,a: str, /) -> Self: ... def __new__(cls,value: str | int) -> Self: ... def __init__(self, value: str | int) -> None: pass _ = Foo(1) # `value=` inlay hint is invalid ``` <img width="143" height="36" alt="Image" src="https://github.com/user-attachments/assets/917b1edc-2a26-4e82-a1ae-4306a6b98b90" />
0 条评论