Skip to content

Abstract method false-positive when using TypeVarTuple #10972

@kdkavanagh

Description

@kdkavanagh

Bug description

False positive specifically when using TypeVarTuple / PEP-695 generics

from __future__ import annotations

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

T = TypeVar("T")


class Base(Generic[T], ABC):
    @abstractmethod
    def get_item(self) -> T: ...


class Middle[NpDtype, *Shape]:
    """Implements the abstract method from Base."""

    def get_item(self) -> NpDtype:
        raise NotImplementedError


class Concrete[NpDtype, *Shape](Middle[NpDtype, *Shape], Base[NpDtype]):
    """All abstract methods are satisfied via Middle."""


obj = Concrete()  # E0110 false positive

Configuration

Command used

pylint -vv

Pylint output

************* Module pylint_e0110_repro                                                             
     pylint_e0110_repro.py:47:6: E0110: Abstract class 'Concrete' with abstract methods instantiated     
     (abstract-class-instantiated)

Expected behavior

No error

Pylint version

$ pylint --version
pylint 4.0.5                                                                                             
astroid 4.0.4                                                                                            
Python 3.12.6 (main, Oct  9 2024, 11:19:43) [GCC 13.2.0]

OS / Environment

No response

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions