Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Create decorator to include the docstrings of the parent class #647

Open
plaguss opened this issue May 17, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@plaguss
Copy link
Contributor

plaguss commented May 17, 2024

Is your feature request related to a problem? Please describe.
The LLM classes could use the docstrings from the parent class, see for example AnyscaleLLM.

Describe the solution you'd like

Using a decorator like:

@add_parent_docstrings()
class AnyscaleLLM(OpenAILLM):
    ...

The decorator should take into account that when parsed using parse_google_docstring, it should include the attributes not found in the current class (the child class takes precedence).

Initial draft:

def add_parent_docstrings(extra_docstrings: Optional[str] = None):
    def docstring_decorator(cls):
        parent_cls_docs = cls.__bases__[0].__doc__
        if extra_docstrings:
            parent_cls_docs += f"\n{extra_docstrings}"
        cls.__doc__ += f"\n{parent_cls_docs}"
        return cls
    return docstring_decorator

Describe alternatives you've considered
Whatever easier way to render nicely the docs from the parent class when required.

Additional context
Add any other context or screenshots about the feature request here.

@plaguss plaguss added the enhancement New feature or request label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant