mesa icon indicating copy to clipboard operation
mesa copied to clipboard

Animal.feed() is documented as abstract but is not enforced as an abstract method

Open sangitabera opened this issue 1 week ago • 4 comments

Describe the bug The Animal.feed() method is documented as an abstract method that should be implemented by subclasses:

def feed(self):
    """Abstract method to be implemented by subclasses."""

However, the method is not decorated with @abstractmethod, and the Animal class does not inherit from ABC.

As a result, Python does not enforce the implementation of feed() in subclasses. A subclass that does not override this method can be instantiated without raising an error, potentially resulting in animals that do not perform any feeding behavior.

Expected behavior The implementation and documentation should be consistent. Either:

  • Make Animal an actual abstract base class using ABC and @abstractmethod so subclasses must implement feed(), or
  • Update the docstring to clarify that feed() is intended to be overridden but is not enforced as abstract.

Actual behavior The method is described as abstract, but Python treats it as an ordinary method with an empty implementation.

sangitabera avatar Nov 21 '26 14:11 sangitabera

Hi @quaquel, could you please take a look at this and share your feedback?

sangitabera avatar Nov 21 '26 14:11 sangitabera

Hi @sangitabera, thanks for reporting this. Were you planning to fix it yourself? If it's free, I'd like to take it — happy to pick another issue if you were already on it.

Nishant-neural avatar Nov 21 '26 19:11 Nishant-neural

Hii @Nishant-neural , thanks for asking. Currently I am working on this issue and just waiting for the feedback then I will open my PR.

sangitabera avatar Nov 21 '26 19:11 sangitabera

hello @sangitabera ,Thanks for letting me know — all yours, I'll pick another issue, good luck!!

Nishant-neural avatar Nov 21 '26 19:11 Nishant-neural