Docstrings, comments, and reference docs must always reflect the current, actual behavior of the code, and all related documentation locations must be updated together. Concretely:
AbstractX, the implementation should enforce/validate that, or the docs should be corrected to describe the real constraints and edge cases (e.g. virtual register()ed subclasses not working as documented).*.rst reference pages, “What’s New” entries, deprecation-timeline tables), not just the primary call site.# comment instead of a triple-quoted docstring, since internal docstrings add no discoverability benefit and needlessly occupy memory.Example of fixing a stale/misleading docstring:
# Bad: docstring doesn't match the new behavior
def __setitem__(self, key, value):
"""Check if the key already exists, return without overwriting"""
...
# Good: update the docstring (or underlying logic) so both agree
def __setitem__(self, key, value):
"""Dictionary style assignment."""
self.__set(key, value, ...)
Applying this consistently keeps documentation trustworthy, avoids contradicting the implementation, and prevents confusion when users or maintainers rely on docs/comments to understand behavior.</description>