Skip to content

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

@mthuurne

Description

@mthuurne

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions