-
Notifications
You must be signed in to change notification settings - Fork 768
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
Python Analysis Inlay Hints Call Argument Names gives useless and confusing names #4543
Comments
tagging @bschnurr |
+1, if a parameter is positional only it shouldn't need a parameter name hint to go with it (since it can't even be used in the first place 😄). Only regular positional/keyword parameters should be hinted, as I see. Thanks for raising this up @amogorkon 🚀 |
I think another way is to trim all the leading underscores, the C/C++ extension does this. The corresponding setting is |
However, in Python leading underscores have special meaning. A single leading underscore usually means that the name of the argument is not part of the puplic API, so usually there's no documentation for those arguments either.
If you remove the leading underscores in Python, you're changing the meaning, invariably leading to a lot of confusion. |
I don't really think it makes sense to use double underscore in parameter name. I would only use double underscore for class attributes. I searched and did not find any information about double underscore in parameters. I would write code like this:
or like this if I really want positional arguments
|
This is not a bug. Names with double underscores have a specific meaning in Python. Prior to PEP 570, there was no formal way to indicate that a function accepted positional-only parameters. Double underscores were used as a convention to indicate this. PEP 570 introduced the special |
Could we introduce a option to trim leading underscores in inlay hints since in recent versions of python this is not needed? |
Trimming the leading underscores will result in an incorrect signature because the parameters will no longer be treated as positional-only. The correct signature could be retained if the double underscores were trimmed and a |
I think that hiding double underscore prefixed inlay hints would be the best way. |
I think it is more reasonable to provide a configuration item whether to hide parameters starting with double underscores. |
This issue has been fixed in prerelease version 2023.9.11, which we've just released. You can find the changelog here: CHANGELOG.md |
Type: Bug
Behaviour
Expected vs. Actual
python.analysis.inlayHints.callArgumentNames enabled produces names as argument names like
__iter1/A
or__obj/data
that are utterly meaningless to the user. I suggest to ignore all name-suggestions that start with__
, since those also usually have no documentation available to the user.Screenshot: https://capture.dropbox.com/kMEbCpqMdPJnM4Ta
Diagnostic data
python.languageServer
setting: PylanceUser Settings
Extension version: 2023.11.11741005
VS Code version: Code - Insiders 1.80.0-insider (b4952d14a465572e33f0635ef58de089227b8876, 2023-06-26T05:32:56.741Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: