-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Minor bug: np.number is not subscriptable #4326
Minor bug: np.number is not subscriptable #4326
Comments
@NeilGirdhar thanks for the report. Looks like numpy brain needs a refresh. |
Same thing for |
If someone is looking to fix this, the files to upgrade are the one starting with |
@NeilGirdhar this bug should be fixed once pylint-dev/astroid#1148 will be merged and by authorizing |
@hippo91 Sounds great. Are there plans to update the numpy brain? If so, should we leave this issue open? |
I'm reopening the issue because what was made in pylint-dev/astroid#1148 was not wise. |
@NeilGirdhar i'm a bit confused with this issue. |
The future import is parsing the annotations as strings. This way the type checker will use the numpy annotations, but the runtime will not try to index the classes. The reason that the runtime cannot index the classes is that numpy has not yet defined the appropriate
Will the brain just work when numpy/numpy#19879 is merged or do you need to do anything on your end? |
Thanks for your answer. However i do not yet understand how the Inside the astroid brain, i try to add the Once the numpy/numpy#19879 pr will be merged, then I will include the |
The future import causes the annotation to be treated as a string. It is as if the programmer had enclosed the annotation in quotation marks. If you're still confused, reading PEP 563 may help.
Thanks for doing this!! One thing, I don't think you should look at future annotations at all. Pylint is a tool that is essentially doing code verification include type verification. Therefore, it should be reading the annotations regardless of the "future annotations". Also, future annotations are standard starting in Python 3.11. Second, if you're conditionally enabling the class getitem, I think I would start considering its existence in numpy 1.20 since that's when it was added to the type stubs. |
@NeilGirdhar thanks for your explanations. I was not probably well awaked yesterday to not understand PEP563 and your first explanation. Sorry. |
You are mistaken: the annotations are supported. What's not supported is running the code like this, but I don't think that's your problem. In short, I think pylint should work like a type checking when it processes annotations, but maybe I'm wrong.
Yes.
Okay, if that's what you want to do. |
The text was updated successfully, but these errors were encountered: