A hint of member starts with 2 underlines was given out of its class #4258
Replies: 3 comments
-
Thanks for the issue but this is actually working as designed. You may or may not want to call private members. They're sorted last as they wouldn't normally be used. There's a 'type checking mode' that will catch these usages though:
Not showing them in completions would be an enhancement request. |
Beta Was this translation helpful? Give feedback.
-
Private class member names are "mangled" by the Python compiler, so they are not accessible from outside the class, at least by their unmangled name. class Foo:
__bar: int = 1
f = Foo()
print(f.__bar) # AttributeError: 'Foo' object has no attribute '__bar' So if the completion provider were to implement this change, it would need to be smart enough to know whether the access is performed inside or outside of the owning class. As you can see from the screen shot above, pyright does distinguish between these two cases when performing its strict-mode |
Beta Was this translation helpful? Give feedback.
-
Moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
-
Environment data
Code Snippet
Repro Steps
When the last line was being typed, a hint would appear as the screenshot:
Expected behavior
do not give hints about members those start with 2 underlines out of their classes, they are 'private' for invoker of these classes.
Actual behavior
The hint as the screenshot.
Logs
no logs for this issue.
Beta Was this translation helpful? Give feedback.
All reactions