Suppose I have:
@dataclass(match_args = True)
class Foo:
# a ton of attributes
...
def update(self, **kwargs):
"""Update the Foo.
Keyword Args:
(a ton of text)
"""
for arg in self.__match_args__:
if arg in kwargs:
self.__dict__[arg] = kwargs[arg]
class Bar:
cfg = Foo()
def set_cfg(self, **kwargs):
"""Set the cfg.
Keyword Args:
see Foo.update
"""
self.cfg.update(**kwargs)
What is the defensible (or proper) way to back-reference Foo's kwargs documentation, so that I can have 100% documentation but avoid copy pasting?
Preferably, it is in a way the IDE will maintain when I refactor. But if it isn't, that is cool too.
json.dumpandjson.dumps, which take the same keyword arguments, is a copy/paste. See github.com/python/cpython/blob/main/Lib/json/__init__.py#L120json.dumps()just says "The arguments have the same meaning as in dump()."