-
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
Support hiding "private" variables/attributes for auto complete #5281
Comments
Can you clarify if this is in completions or debugger or both? Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision. |
Hi, I am not the original poster, but I believe I could (try to) clarify. |
Whould be nice to have something like: |
@karthiknadig Somehow I never saw your message until now (over a year later). @Mirandatz is correct, this would only apply to auto-completion. |
Thanks for the hint, works like a charm. Only problem is, that one cannot set this globally… |
This comment has been minimized.
This comment has been minimized.
Apologies for the confusion, the issues I had liked above was for debugging and not auto completion. I tweaked the title of this issue to be a bit more clear. |
Any way to achieve either hiding private methods in intellisense or at least showing them last rather than first? |
They are currently sorted last. I'm not sure when this changed. If you'd prefer that they be omitted from the suggestion list, please up-vote this enhancement request: #4258 |
I'm facing a similar problem with private attributes in pydantic:
But when I got to get the fields auto-completion, I now see public fields only: There is one place where this verbose fields list is acceptable, and it is the class-preview block on hover:
@debonte would you say this example is related to the discussed enhancement request? or should I open a new separate issue? |
@idan22moral, please open a separate issue. It's not clear to me that we should ever hide parameters in signature help. You're welcome to argue for your desired behavior in a separate issue though.
That hover info isn't for the class, but rather for the generated Btw, Pylance's support for pydantic's data classes comes via their use of If you switch from from pydantic import BaseModel, Field
class Magic(BaseModel):
_private_field: str = Field(init=False, default="blabla")
regular_field: str |
@debonte I've just finished writing my proposal to Pydantic regarding the discussed behavior, and now I see your comment. Funny timing 🤭 After some digging (since Pydantic internals, dataclasses and Pylance+Pyright are new areas for me), As you said, the problem is not with Pylance/Pyright, but the field specifiers listed by Pydantic. Thanks again for your informative comment! |
While Python does not technically have private variables, it is a standardized in PEP8 that single and double underscores at the start of a variable name means that the variable is for internal use only. Some Python IDEs support this, and do not display variables with such prefixes outside of their scope. It would be nice if there was a setting in VS code to enable this behavior.
Source: https://www.python.org/dev/peps/pep-0008/#id36
The text was updated successfully, but these errors were encountered: