Skip to content

False positive inherit-non-class when inheriting a generic Protocol #9106

@KholdStare

Description

@KholdStare

Bug description

In the official Protocol PEP, inheriting directly from a protocol is ok: https://peps.python.org/pep-0544/#explicitly-declaring-implementation

However pylint 3 complains about inheriting from a generic protocol such as below:

class Channel(Protocol[T]):
    """A communication channel between nodes that can be closed"""

    async def get(self) -> T:
        """Raises GeneratorExit when no more values are available"""

    async def put(self, value: T):
        ...

    async def close(self) -> None:
        ...


class DirectChannel(Channel[T]):
    # etc..

Configuration

No response

Command used

pylint .

Pylint output

************* Module uflow.channel
src/uflow/channel.py:115:0: E0239: Inheriting 'Channel[T]', which is not a class. (inherit-non-class)
src/uflow/channel.py:158:0: E0239: Inheriting 'Channel[T]', which is not a class. (inherit-non-class)

Expected behavior

This should not be an error.

Pylint version

pylint 3.0.0
astroid 3.0.0
Python 3.10.10 (main, Aug 24 2023, 21:59:21) [GCC 10.2.1 20210110]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions