This repository has been archived by the owner on May 8, 2023. It is now read-only.
Add hp.from_init_signature
helper method
#97
Labels
Needs Design
Further design is required. Do not start implementation until design questions are resolved.
Consider the following:
It's kinda redundant to have to copy and paste the docstring and default value in the yahp dataclass. Wouldn't it be nice if you could just do this?
Implementation
This should be possible via python's
inspect
and https://pypi.org/project/docstring-parser/As for the API, I'm thinking something like this:
Other Designs
Originally, I thought it would have been nice to support the following:
However,
hp.from_init_signature
would not know whether to return ahp.optional
orhp.required
since it doesn't know the field name. It is impossible to set this information later (such as on__init_subclass__
), since python's dataclasses parses this on the@dataclass
decorator. We would need our own@yahp_datalcass
decorator to preprocess the class before passing it to python's dataclasses. This is a feature that can be done later if this is a design that we want...The text was updated successfully, but these errors were encountered: