How to properly subclass a class when the parent class returns nothing and the subclass does

Viewed 38

I'm using Pycharm to develop and my code is not pep8 but the code works, I get blocked text and when you hover over it says reference error.
in the parent class there is a method call insert() and it returns nothing. in the subclass I want to override insert() and it returns some value. it all works but the error message says insert() returns nothing when it really does. How I get Pycharm to know that the insert() function returns something?

The method I'm overriding is insert() from collections lib. https://docs.python.org/3/library/collections.html#collections.deque Like I said it works it's just is not pep8 in Pycharm.

My method is below.

def append(self, item):
    new_item = None
    if isinstance(item, Leaf) or isinstance(item, Node):
        super(Node, self).append(item)
        new_item = self[len(self)-1]
        if new_item.parent is None:
            new_item.parent = self

        item.id = self.tree.next_id()
        _list = [None] * (len(self.tree.headings) - len(item.columns))
        item.columns += _list
    return new_item
0 Answers
Related