Skip to content

False positive __init__ method from base class is not called when the constructor raises NotImplementedError without using abc #3975

Closed
@cpitclaudel

Description

@cpitclaudel

Is your feature request related to a problem? Please describe

In the following example, Pylint flags the Derived's __init__ method because it doesn't call Bases's __init__.

class Base:
    def __init__(self, a: int, b: str):
        raise NotImplementedError()

class Derived(Base):
    def __init__(self, a: int, b: str):
        self.a = a + 1
        self.b = b[::-1]

This is discussed here: https://stackoverflow.com/questions/25072363/error-init-method-from-base-class-is-not-called-for-an-abstract-class

Describe the solution you'd like

Pylint could (should?) detect this case and not report an error.

Additional context

An easy fix is to remove the init in the base class, but it can be useful to have it there to define what signature __init__ should have.

Metadata

Metadata

Assignees

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

Relationships

None yet

Development

No branches or pull requests

Issue actions