Skip to content

Abstract OOP class / method inheritance / analyzing misbehaving #10192

Open
@clauspruefer

Description

Bug description

get_value_by_property_id() is not defined as abstract method (@abc.abstractmethod decorator) but pylint treats like.

import abc

class BaseHandler(metaclass=abc.ABCMeta):
    """ Abstract Base Class (ABC) Meta Class.
    """
    def __init__(self):
        self.logger = logging.getLogger(__name__)

    @abc.abstractmethod
    def _add_class(self):
        """ Abstract _add_class() method.
        """
        pass

    def get_value_by_property_id(self, property_id):
        raise NotImplementedError


class ClassHandler(BaseHandler):
    """ ClassHandler class. Inherits BaseHandler class.
    """

    def __init__(self):
        super().__init__()

Configuration

name: Pylint

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ "3.10" ]
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install pylint
        pip install microesb

Command used

pylint $(git ls-files 'src/microesb.py')

Pylint output

Method get_value_by_property_id is abstract in class BaseHandler but is not overridden in child class 'ClassHandler'.

Expected behavior

No Exception should be raised by pylint.

Pylint version

pylint-3.3.3-py3-none-any.whl

OS / Environment

GitHub Actions / Docker

Additional dependencies

Metadata

Assignees

No one assigned

    Labels

    Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions