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

False positive unsubscriptable-object with typing.Dict instances #3129

Closed
mthuurne opened this issue Sep 25, 2019 · 4 comments
Closed

False positive unsubscriptable-object with typing.Dict instances #3129

mthuurne opened this issue Sep 25, 2019 · 4 comments
Assignees
Labels

Comments

@mthuurne
Copy link
Contributor

Steps to reproduce

Run pylint on the following code:

from typing import Dict

class Translator(Dict[str, str]):
    pass

t = Translator(beep='hello', bloop='world')
print(t['beep'], t['bloop'])

Current behavior

pylint reports:

E1136: Value 't' is unsubscriptable (unsubscriptable-object)
E1136: Value 't' is unsubscriptable (unsubscriptable-object)

Expected behavior

No message is reported, since t acts just like a dict.

pylint --version output

pylint 2.4.0
astroid 2.3.0
Python 3.7.2 (default, Feb 26 2019, 13:02:33) 
[GCC 7.3.1 20180323 [gcc-7-branch revision 258812]]

Note

While superficially similar, this is different from #2849 since there the problem is in subscripting the type, while here subscripting the type is accepted but subscripting the instance is not.

@mthuurne mthuurne changed the title False positive unsubscriptable-object with typing.Dict False positive unsubscriptable-object with typing.Dict instances Sep 25, 2019
@PCManticore
Copy link
Contributor

Thanks, I can reproduce it as well.

@ZeeD
Copy link

ZeeD commented Apr 1, 2020

Is there an ETA for this issue?

@mthuurne
Copy link
Contributor Author

I can't reproduce this with the git master versions of PyLint and Astroid, on Python 3.8. I don't understand yet why though.

attilaolah pushed a commit to attilaolah/math that referenced this issue Jun 2, 2020
This is temporary, until pylint-dev/pylint#3129 is resolved.
b3b added a commit to b3b/ipython-restmagic that referenced this issue Aug 12, 2020
@AWhetter
Copy link
Contributor

AWhetter commented Sep 8, 2020

I'm going to close this in favour of #2420 because it covers a wider set of issues associated with inheriting from typing.Dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants