labthings_fastapi.example_things ================================ .. py:module:: labthings_fastapi.example_things .. autoapi-nested-parse:: Example Thing subclasses, used for testing and demonstration purposes. Most of these are broken in some way and used for testing. These should be moved into the unit tests. Classes ------- .. autoapisummary:: labthings_fastapi.example_things.MyThing labthings_fastapi.example_things.ThingWithBrokenAffordances labthings_fastapi.example_things.ThingThatCantInstantiate labthings_fastapi.example_things.ThingThatCantStart Package Contents ---------------- .. py:class:: MyThing Bases: :py:obj:`labthings_fastapi.thing.Thing` An example Thing with a few affordances. .. py:method:: anaction(repeats: Annotated[int, Field(description='The number of times to try the action')], undocumented: int, title: Annotated[str, Field(description='the title of the invocation')] = 'Untitled', attempts: Annotated[Optional[list[str]], Field(description='Names for each attempt - I suggest final, Final, FINAL.')] = None) -> dict[str, str] Quite a complicated action. This action has lots of parameters and is designed to confuse my schema generator. I hope it doesn't! I might even use some Markdown here: * If this renders, it supports lists * With at least two items. There is also a parameter and return block to satisfy docstring validators. This may be preferable to annotations on the arguments. :param repeats: How many times to do it. :param undocumented: There's no description on this field's type hint. :param title: A human-readable title. :param attempts: A list of names of attempts. :return: A dictionary with strings as keys and values. .. py:method:: make_a_dict(extra_key: Optional[str] = None, extra_value: Optional[str] = None) -> dict[str, Optional[str]] Do something that returns a dict. :param extra_key: An additional key. :param extra_value: An additional value. :return: a dictionary. .. py:method:: increment_counter() Increment the counter property. This action doesn't do very much - all it does, in fact, is increment the counter (which may be read using the `counter` property). .. py:method:: slowly_increase_counter(increments: int = 60, delay: float = 1) Increment the counter slowly over a minute. :param increments: how many times to increment. :param delay: the wait time between increments. .. py:attribute:: counter .. py:attribute:: foo .. py:method:: action_without_arguments() -> None Do something that takes no arguments. .. py:method:: action_with_only_kwargs(**kwargs: dict) -> None Do something that takes \**kwargs. :param \**kwargs: Keyword arguments. .. py:class:: ThingWithBrokenAffordances Bases: :py:obj:`labthings_fastapi.thing.Thing` A Thing that raises exceptions in actions/properties. .. py:method:: broken_action() Do something that raises an exception. :raise RuntimeError: every time. .. py:method:: broken_property() Raise an exception when the property is accessed. :raise RuntimeError: every time. .. py:class:: ThingThatCantInstantiate Bases: :py:obj:`labthings_fastapi.thing.Thing` A Thing that raises an exception in __init__. Fail to initialise. :raise RuntimeError: every time. .. py:class:: ThingThatCantStart Bases: :py:obj:`labthings_fastapi.thing.Thing` A Thing that raises an exception in __enter__. .. py:method:: __enter__() Fail to start the thing. :raise RuntimeError: every time. .. py:method:: __exit__(exc_t: Any, exc_v: Any, exc_tb: Any) Don't leave the thing as we never entered. :param exc_t: Exception type. :param exc_v: Exception value. :param exc_tb: Traceback.