Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

doc_inherit.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. """
  2. This is a working hack to provide inherited docstrings.
  3. The only other working way I tried would involve metaclasses.
  4. Each method to inherit a docstring is flagged using the @inherit_docstring
  5. decorator.
  6. The actual inheritance is done in the class decorator @allow_inherit_docstring,
  7. which uses the classes base-classes and its mro and copies the first docstring
  8. it finds.
  9. """
  10. def allow_inherit_docstring(cls):
  11. bases = cls.__bases__
  12. for attr, attribute in cls.__dict__.items():
  13. if hasattr(attribute, "inherit_docstring"):
  14. if not attribute.__doc__:
  15. for mro_cls in (mro_cls for base in bases
  16. for mro_cls in base.mro()
  17. if hasattr(mro_cls, attr)):
  18. doc = getattr(getattr(mro_cls, attr), '__doc__')
  19. if doc:
  20. attribute.__doc__ = doc
  21. break
  22. return cls
  23. def inherit_docstring(obj):
  24. obj.inherit_docstring = True
  25. return obj