config_wrangler.config_types.dynamically_referenced module
- config_wrangler.config_types.dynamically_referenced.DynamicField(default: Any = PydanticUndefined, *, default_factory: Callable[[], Any] | None = PydanticUndefined, alias: str | None = PydanticUndefined, alias_priority: int | None = PydanticUndefined, validation_alias: str | AliasPath | AliasChoices | None = PydanticUndefined, serialization_alias: str | None = PydanticUndefined, title: str | None = PydanticUndefined, description: str | None = PydanticUndefined, examples: list[Any] | None = PydanticUndefined, exclude: bool | None = PydanticUndefined, include: bool | None = PydanticUndefined, discriminator: str | None = PydanticUndefined, json_schema_extra: dict[str, Any] | Callable[[dict[str, Any]], None] | None = PydanticUndefined, frozen: bool | None = PydanticUndefined, validate_default: bool | None = PydanticUndefined, repr: bool = PydanticUndefined, init_var: bool | None = PydanticUndefined, kw_only: bool | None = PydanticUndefined, pattern: str | None = PydanticUndefined, strict: bool | None = PydanticUndefined, gt: float | None = PydanticUndefined, ge: float | None = PydanticUndefined, lt: float | None = PydanticUndefined, le: float | None = PydanticUndefined, multiple_of: float | None = PydanticUndefined, allow_inf_nan: bool | None = PydanticUndefined, max_digits: int | None = PydanticUndefined, decimal_places: int | None = PydanticUndefined, min_length: int | None = PydanticUndefined, max_length: int | None = PydanticUndefined, delimiter: str = ',') Any[source]
Create a field for a list of objects, plus other Pydantic Field configuration options.
Pydantic standard docs:
Used to provide extra information about a field, either for the model schema or complex validation. Some arguments apply only to number fields (int, float, Decimal) and some apply only to str.
- Parameters:
default¶ – Default value if the field is not set.
default_factory¶ – A callable to generate the default value, such as
utcnow().alias¶ – An alternative name for the attribute.
alias_priority¶ – Priority of the alias. This affects whether an alias generator is used.
validation_alias¶ – ‘Whitelist’ validation step. The field will be the single one allowed by the alias or set of aliases defined.
serialization_alias¶ – ‘Blacklist’ validation step. The vanilla field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.
title¶ – Human-readable title.
description¶ – Human-readable description.
examples¶ – Example values for this field.
exclude¶ – Whether to exclude the field from the model schema.
include¶ – Whether to include the field in the model schema.
discriminator¶ – Field name for discriminating the type in a tagged union.
json_schema_extra¶ – Any additional JSON schema data for the schema property.
frozen¶ – Whether the field is frozen.
validate_default¶ – Run validation that isn’t only checking existence of defaults. True by default.
repr¶ – A boolean indicating whether to include the field in the __repr__ output.
init_var¶ – Whether the field should be included in the constructor of the dataclass.
kw_only¶ – Whether the field should be a keyword-only argument in the constructor of the dataclass.
strict¶ – If True, strict validation is applied to the field. See [Strict Mode](../usage/strict_mode.md) for details.
gt¶ – Greater than. If set, value must be greater than this. Only applicable to numbers.
ge¶ – Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.
lt¶ – Less than. If set, value must be less than this. Only applicable to numbers.
le¶ – Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.
multiple_of¶ – Value must be a multiple of this. Only applicable to numbers.
min_length¶ – Minimum length for strings.
max_length¶ – Maximum length for strings.
pattern¶ – Pattern for strings.
allow_inf_nan¶ – Allow inf, -inf, nan. Only applicable to numbers.
max_digits¶ – Maximum number of allow digits for strings.
decimal_places¶ – Maximum number of decimal places allowed for numbers.
delimiter¶ – delimiter to use when parsing the input value
- Returns:
- A new [FieldInfo][pydantic.fields.FieldInfo], the return annotation is Any so Field can be used on
type annotated fields without causing a typing error.
- class config_wrangler.config_types.dynamically_referenced.DynamicFieldInfo(delimiter=',', **kwargs)[source]
Bases:
DelimitedListFieldInfo- __init__(delimiter=',', **kwargs) None[source]
This class should generally not be initialized directly; instead, use the pydantic.fields.Field function or one of the constructor classmethods.
See the signature of pydantic.fields.Field for more details about the expected arguments. Unknown keyword arguments are accepted (and ignored) for backwards compatibility.
- static from_field(default: Any = PydanticUndefined, **kwargs: Unpack[_FromFieldInfoInputs]) DynamicFieldInfo[source]
Create a new FieldInfo object with the Field function.
- Parameters:
- Raises:
TypeError – If ‘annotation’ is passed as a keyword argument.
- Returns:
A new FieldInfo object with the given parameters.
Example
This is how you can create a field with default value
- class MyModel(pydantic.BaseModel):
foo: int = pydantic.Field(4)
- pydantic model config_wrangler.config_types.dynamically_referenced.DynamicallyReferenced[source]
Bases:
ConfigHierarchyRepresents a reference to a statically defined section of the config. The data type of the section can be any subclass of ConfigHierarchy. The validator will check that the reference exists.
- Config:
validate_default: bool = True
validate_assignment: bool = True
validate_credentials: bool = True
- Fields:
ref (str)
- Validators:
_validate_phase_1»ref
- add_child(name: str, child_object: ConfigHierarchy)
Set this configuration as a child in the hierarchy of another config. For any programmatically created config objects this is required so that the new object ‘knows’ where it lives in the hierarchy – most importantly so that it can find the hierarchies root object.
- full_item_name(item_name: str | None = None, delimiter: str = ' -> ')
The fully qualified name of this config item in the config hierarchy.
- get_copy(copied_by: str = 'get_copy') ConfigHierarchy
Copy this configuration. Useful when you need to programmatically modify a configuration without modifying the original base configuration.
- get_referenced() ConfigHierarchy[source]
- model_dump_non_private(*, mode: Literal['json', 'python'] | str = 'python', exclude: Set[str] | None = None) dict[str, Any]
- set_as_child(name: str, other_config_item: ConfigHierarchy)
- static translate_config_data(config_data: MutableMapping)
Children classes can provide translation logic to allow older config files to be used with newer config class definitions.
- pydantic model config_wrangler.config_types.dynamically_referenced.ListDynamicallyReferenced[source]
Bases:
ConfigHierarchy- Config:
validate_default: bool = True
validate_assignment: bool = True
validate_credentials: bool = True
- Fields:
refs (List[config_wrangler.config_types.dynamically_referenced.DynamicallyReferenced])
- add_child(name: str, child_object: ConfigHierarchy)
Set this configuration as a child in the hierarchy of another config. For any programmatically created config objects this is required so that the new object ‘knows’ where it lives in the hierarchy – most importantly so that it can find the hierarchies root object.
- full_item_name(item_name: str | None = None, delimiter: str = ' -> ')
The fully qualified name of this config item in the config hierarchy.
- get_copy(copied_by: str = 'get_copy') ConfigHierarchy
Copy this configuration. Useful when you need to programmatically modify a configuration without modifying the original base configuration.
- model_dump_non_private(*, mode: Literal['json', 'python'] | str = 'python', exclude: Set[str] | None = None) dict[str, Any]
- set_as_child(name: str, other_config_item: ConfigHierarchy)
- static translate_config_data(config_data: MutableMapping)
Children classes can provide translation logic to allow older config files to be used with newer config class definitions.