Skip to content

unsubscriptable-object error reported for abstract generic types #2822

Closed
@aviv-ebates

Description

@aviv-ebates

(This might be a part of #2416, but I already have those changes)
Pylint reports unsubscriptable-object for abstract generic types:

Steps to reproduce

Run pylint on following file:

from typing import TypeVar, Generic
from abc import ABCMeta, abstractmethod

T = TypeVar('T')

class Factory(Generic[T], metaclass=ABCMeta):
    @abstractmethod
    def build(self) -> T:
        pass

class IntFactory(Factory[int]):  # Sadpanda unsubscriptable-object
    def build(self) -> int:
        return 3

factory = IntFactory()

x: int = factory.build()

Current behavior

Pylint reports E1136: Value 'Factory' is unsubscriptable (unsubscriptable-object) on line 11.

Expected behavior

As far as I understand, this is supposed to be ok? mypy 0.660 doesn't complain and python 3.7.1 runs the whole thing.

pylint --version output

pylint 2.3.1
astroid 2.2.5
Python 3.7.1 (default, Oct 22 2018, 11:21:55)
[GCC 8.2.0]

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