Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we remove abstract-method? #10054

Open
mbyrnepr2 opened this issue Oct 29, 2024 · 0 comments
Open

Should we remove abstract-method? #10054

mbyrnepr2 opened this issue Oct 29, 2024 · 0 comments
Labels
Needs decision 🔒 Needs a decision before implemention or rejection Proposal 📨

Comments

@mbyrnepr2
Copy link
Member

Current problem

abstract-method documentation.

The documentation states that this message is emitted when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class.

A concrete class is one where all the abstract methods have been implemented.

The problem with abstract-method is that we don't know for sure if a class is intended to be a concrete class or not. The only way we would know for sure is if it does contain all of the implemented abstract methods - but by that point the check is not useful.

The following scenario (modified from one of the examples in the documentation) is valid Python but it would emit abstract-method:

class Pet:
    def make_sound(self):
        raise NotImplementedError


class Cat(
    Pet
):  #  W0223: Method 'make_sound' is abstract in class 'Pet' but is not overridden in child class 'Cat' (abstract-method)
    def jump_up(self):
        print("jump!")


class Tiger(Cat):
    """This is the concrete class"""
    def make_sound(self):
        print("rrr!")


Tiger().make_sound()
Tiger().jump_up()

The other example from the documentation emits abstract-method; however the base class does not inherit from abc.ABC, so this example emits a warning even though the class, which is not implementing the abstract method, instantiates without error:

import abc


class WildAnimal:
    @abc.abstractmethod
    def make_sound(self):
        pass


class Panther(WildAnimal):  # [abstract-method]
    pass


Panther().make_sound()

Desired solution

Deprecate and remove abstract-method.

Additional context

#9979
#7950
#3098

Related message https://pylint.readthedocs.io/en/latest/user_guide/messages/error/abstract-class-instantiated.html

@mbyrnepr2 mbyrnepr2 added Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Proposal 📨 Needs decision 🔒 Needs a decision before implemention or rejection and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs decision 🔒 Needs a decision before implemention or rejection Proposal 📨
Projects
None yet
Development

No branches or pull requests

1 participant