You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEP585 specifies that type implements __class_getitem__, yet pylint still errors. However, this does not occur with other PEP585 types such as list or tuple, which I believe was previously fixed. type also needs to be fixed in the same way.
Steps to reproduce
Create file a.py:
a: type[int] = int
Run pylint --rcfile=/dev/null a.py
Current behavior
************* Module a
a.py:1:0: C0114: Missing module docstring (missing-module-docstring)
a.py:1:3: E1136: Value 'type' is unsubscriptable (unsubscriptable-object)
----------------------------------------------------------------------
Your code has been rated at -50.00/10 (previous run: -50.00/10, +0.00)
Expected behavior
Only the missing-module-docstring line should be printed, not the unsubscriptable-object.
@SuperStormer thanks for your report. I can reproduce it.
The problem seems to come form the fact that in python3.9 the type object has no __class_getitem__ method whereas, for example, listobject has one.
In [7]: type.__class_getitem__
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-00c2935419fa> in <module>
----> 1 type.__class_getitem__
AttributeError: type object 'type' has no attribute '__class_getitem__'
In [8]: list.__class_getitem__
Out[8]: <function list.__class_getitem__>
@PCManticore i think we would need an astroid brain to handle this. What do you think about it? By the way is it possible and a good idea to enable a brain for a specific python version?
PEP585 specifies that
type
implements__class_getitem__
, yet pylint still errors. However, this does not occur with other PEP585 types such as list or tuple, which I believe was previously fixed.type
also needs to be fixed in the same way.Steps to reproduce
pylint --rcfile=/dev/null a.py
Current behavior
Expected behavior
Only the missing-module-docstring line should be printed, not the unsubscriptable-object.
pylint --version output
Installed via
pip install git+https://github.com/PyCQA/pylint/ git+https://github.com/PyCQA/astroid
pylint commit b3b8ed2
astroid commit 99d9c77cc276b1c5f5d76d91282d05b5df3a2c21
The text was updated successfully, but these errors were encountered: