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

Wrong attribute prompt about the built-in attribute “__name__" of class. #154

Closed
CatNofishing opened this issue Jul 22, 2020 · 9 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@CatNofishing
Copy link

According to the python official doc, the attribute "name" is just the class ,type ,etc. So the instance can not get the attribute "name", but the pyplance show the "name" attr in instance .

image

@erictraut
Copy link
Contributor

Thanks for the bug report. This will be fixed in the next version of Pyright and Pylance.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version labels Jul 22, 2020
@CatNofishing
Copy link
Author

@erictraut Thanks for your reply.😁
Besides attribute "name" has this problem, I find that all attributes marked by the flag below have this problem.
image

This flag represents "Class" instead of attributes.
image

@erictraut
Copy link
Contributor

Thanks, this will be fixed as well.

@jakebailey
Copy link
Member

jakebailey commented Jul 29, 2020

This issue has been fixed in version 2020.7.4, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202074-29-july-2020

@CatNofishing
Copy link
Author

@jakebailey @erictraut
I noticed that you solve this problem by improving grammar checking (linting) , but these attribute hints still exist in smart suggestions. I think you should completely hide these attributes that are not instance attributes from the parameter prompt list
image
image

@erictraut
Copy link
Contributor

Thanks for the bug report. You are correct that most of these attributes should not appear on instances. The __annotations__ attribute is found on objects (as defined in builtins.pyi), but the others should appear as attributes in classes.

This will be fixed in the next release of Pylance.

@erictraut erictraut reopened this Aug 25, 2020
@CatNofishing
Copy link
Author

CatNofishing commented Aug 25, 2020

image
https://docs.python.org/3/library/stdtypes.html?highlight=built
I am not sure if other special attributes and methods have similar problems, this is the relevant information I can find according to the official documentation.
The follow is what I can find. Please check it.
image

@erictraut
Copy link
Contributor

We previously hard-coded some of these attribute names. I've removed these hard-coded names and now use the type metaclass and the object base class (both defined in builtins.pyi) to determine which attributes to include for classes and instances. The attributes should now match what you see in builtins.pyi. If that list defined in the type or object class looks wrong to you, you can submit a PR to the typeshed repo to add or remove attributes.

@jakebailey
Copy link
Member

This issue has been fixed in version 2020.8.3, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202083-28-august-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants