-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, the settings for Monster and Victor are only partially set as parameters during instantiation, while several are class or instance attributes. Furthermore, the init method has more than the 5 max parameters recommended by PEP.
I have not refactored yet because it is low priority. One wee detail is that I need to think how best to do this in regards to documentation. I most like will do
something like:
from typing_extensions import Unpack, TypedDict # Unpack is a 3.10 feature and TypedDict is 3.7 but colab is 3.6
class FooOptions(TypedDict):
"""
done properly with :param a: etc.
"""
a: int
b: str
class BarOptions(FooOptions):
"""
done properly with :param c: etc.
"""
c: float
d: bool
e: Dict[str, int]
class Bar:
"""
bla bla.
"""
def __init__(self, data: list, **options: Unpack[BarOptions]):
pass
BarOptions.__doc__ += 'Options from FooOptions: ' + FooOptions.__doc__
Bar.__doc__ += 'Options: ' + BarOptions.__doc__Using the .. autoclass auto-api feature of sphinx in a docstring (if it even works) would require a lot of tweaks as I'd want the inherited members of FooOptions shown, but the TypedDict members. Whereas filling out the RST params entries is not a massive deal.
Hopefully by raising an issue I will get round to fixing it!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request