xeofs icon indicating copy to clipboard operation
xeofs copied to clipboard

Avoid recreating API on every child model class

Open nicrie opened this issue 1 year ago • 1 comments

Looking again at the inheritance structure, I'm noticing we recreate the entire API on every child model class. This has the benefit of making the signature explicit and the auto built docstrings complete, but it also becomes a hassle to maintain such long argument lists. For example I also had to add verbose back to these classes to get the parameter serialization list complete.

An alternative is to only specify whatever new parameters are included on the child class and pass everything else to the parent with **kwargs, but this makes the signature less explicit. We could consider something like pydantic's BaseModel which I believe helps with this. Just something for future consideration.

Originally posted by @slevang in https://github.com/xarray-contrib/xeofs/pull/196#discussion_r1739904352

nicrie avatar Sep 05 '24 12:09 nicrie

Looks like this might "just work" in the docs by adding autodoc_inherit_docstrings = True to the conf.py.

slevang avatar Sep 05 '24 13:09 slevang