Can the @staticmethod of a parent class call a @staticmethod+@abstractmethod implemented by a child class?

29 Views Asked by At

My class A has some methods that are, both, abstractmethods and staticmethods.

class A(ABC):
    @staticmethod
    @abstractmethod
    def foo():
        pass

    @staticmethod
    def bar():
        A.foo()

Class B is a subclass of A and implements the abstractmethods.

class B(A):
    @staticmethod
    def foo():
        print("B.foo")

When I call B.bar(), I'd expect to see "B.foo", however, when I debug the code, I see that A.foo() is called.

B.bar() # doesn't print anything

Can A.bar() call B.foo()'s implementation?

0

There are 0 best solutions below