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

Cleanup parameters #29

Open
matteoferla opened this issue Jun 29, 2022 · 0 comments
Open

Cleanup parameters #29

matteoferla opened this issue Jun 29, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@matteoferla
Copy link
Owner

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!

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