Skip to content

Cleanup parameters #29

@matteoferla

Description

@matteoferla

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions