Skip to content

fastapi_tools.params.sample_params

Values for sample params of sample config.

Classes:

SampleParams

SampleParams()

Sample params for sample config.

Load the sample params.

Methods:

  • __str__

    Return the string representation of the object.

  • to_config

    Convert params to config.

Source code in src/fastapi_tools/params/sample_params.py
def __init__(self) -> None:
    """Load the sample params."""
    self.some_int: int = 42
    self.nested_model_some_str: str = "Hello, Params!"
    self.custom_kwargs: dict = {"key1": "value1", "key2": "value2"}

__str__

__str__() -> str

Return the string representation of the object.

Source code in src/fastapi_tools/params/sample_params.py
def __str__(self) -> str:
    """Return the string representation of the object."""
    s = "SampleParams:"
    s += f"\n  some_int: {self.some_int}"
    s += f"\n  nested_model_some_str: {self.nested_model_some_str}"
    s += f"\n  custom_kwargs: {self.custom_kwargs}"
    return s

to_config

to_config() -> SampleConfig

Convert params to config.

Source code in src/fastapi_tools/params/sample_params.py
def to_config(self) -> SampleConfig:
    """Convert params to config."""
    return SampleConfig(
        some_int=self.some_int,
        nested_model=NestedModel(
            some_str=self.nested_model_some_str,
        ),
        kwargs=self.custom_kwargs,
    )