8000 Generic class is unsubscriptable · Issue #3520 · pylint-dev/pylint · GitHub
[go: up one dir, main page]

Skip to content
Generic class is unsubscriptable #3520
@Foobin

Description

@Foobin

This issue is almost identical to #2416. The difference between my issue and #2416 is where the error occurs.

Steps to reproduce

I have the following class

T = TypeVar('T', bound=Component)

class MyClass(Component, Generic[T]): # in #2416 the unsubscriptable error occurs here
    pass

The above has no pylint errors, as expected. However, I am unable to create instances of MyClass, or inherit from MyClass without an unsubscriptable error popping up in the editor. The code itself runs fine:

class Foo(Component):
    pass

instance = MyClass[Foo]()  # -> Value 'MyClass' is unsubscriptable

class InheritMyClass(MyClass[Foo]): # -> Value 'MyClass' is unsubscriptable
    pass

Current behavior

Value 'MyClass' is unsubscriptable --- pylint(unsubscriptable-object)

pylint --version output

I am using the pylint bundled with the newest version (2020.4.74986 (20 April 2020)) of Microsoft's Python extension for vscode,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0