![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|
Functions | |
| list[type] | _make_subclasses_tree (type cl) |
| bool | _has_subclasses (type cl, tuple[type,...] given_subclasses) |
| type|None | _get_union_type (type cl, tuple[type] given_subclasses_tree) |
| None | include_subclasses (type cl, C converter, tuple[type,...]|None subclasses=None, Callable[[Any, C], Any]|None union_strategy=None, dict[str, AttributeOverride]|None overrides=None) |
| _include_subclasses_without_union_strategy (cl, BaseConverter converter, tuple[type] parent_subclass_tree, dict[str, AttributeOverride]|None overrides) | |
| _include_subclasses_with_union_strategy (C converter, tuple[type,...] union_classes, Callable[[Any, C], Any] union_strategy, dict[str, AttributeOverride]|None overrides) | |
Variables | |
| C = TypeVar("C", bound=BaseConverter) | |
Strategies for customizing subclass behaviors.
|
protected |
Whether the given class has subclasses from `given_subclasses`.
|
protected |
This function is tricky because we're dealing with what is essentially a circular reference. We need to generate a structure hook for a class that is both: * specific for that particular class and its own fields * but should handle specific functions for all its descendants too Hence the dance with registering below.
| None cattrs.strategies._subclasses.include_subclasses | ( | type | cl, |
| C | converter, | ||
| tuple[type, ...] | None | subclasses = None, |
||
| Callable[[Any, C], Any] | None | union_strategy = None, |
||
| dict[str, AttributeOverride] | None | overrides = None |
||
| ) |
Configure the converter so that the attrs/dataclass `cl` is un/structured as if it
was a union of itself and all its subclasses that are defined at the time when this
strategy is applied.
:param cl: A base `attrs` or `dataclass` class.
:param converter: The `Converter` on which this strategy is applied. Do note that
the strategy does not work for a :class:`cattrs.BaseConverter`.
:param subclasses: A tuple of sublcasses whose ancestor is `cl`. If left as `None`,
subclasses are detected using recursively the `__subclasses__` method of `cl`
and its descendents.
:param union_strategy: A callable of two arguments passed by position
(`subclass_union`, `converter`) that defines the union strategy to use to
disambiguate the subclasses union. If `None` (the default), the automatic unique
field disambiguation is used which means that every single subclass
participating in the union must have an attribute name that does not exist in
any other sibling class.
:param overrides: a mapping of `cl` attribute names to overrides (instantiated with
:func:`cattrs.gen.override`) to customize un/structuring.
.. versionadded:: 23.1.0
.. versionchanged:: 24.1.0
When overrides are not provided, hooks for individual classes are retrieved from
the converter instead of generated with no overrides, using converter defaults.