Is it ok to use children method in abstract class? pep8 says instance has no member

Viewed 414

I use pep8 in visual studio code and I just tried to write some abstract classes.

The problem is I get the error [pylint] E1101:Instance of 'MyAbstract' has no 'child_method' member because pep8 does not realise that the method is well defined, but in the child classes.

To illustrate my problem here is a code snippet that is reducted to the minimum for clarity:

class MyAbstract:

    def some_method(self):
        newinfo = self.child_method()
        # use newinfo 

class MyChild(MyAbstract):

    def child_method(self):
        # Do something in a way

class OtherChild(MyAbstract):

    def child_method(self):
        # Do the same thing in a different way

So my questions are:

  • Is it ok to write classes like this?
  • How would you solve the error? (disable error, use another pattern, ...)

Clarification

The MyAbstract class shouldn't be instanciated, and the child classes will inherit the some_method. The idea is to use it on child class instances.

1 Answers
Related