Method Models And Signatures#

Global variable for models#

fitrequest.method_models.environment_models = {}#

Global dictionnary used to map json/yaml declared models to actual python models.

Hint

Don’t forget to update this dictionnary with custom models when using them in yaml/json files.

Models signatures#

pydantic model fitrequest.method_models.AttrSignature[source]#

Bases: BaseModel

Represents the signature of the attribute.

Fields:
field alias: str | None = None#
field annotation: str [Required]#
field attr_type: Literal['arg', 'kwarg'] [Required]#
field default_value: str | None = None#
field name: str [Required]#
property param_name: str#

Return the name used in the request params.

property signature: str#

Dumps flattened signature of the attribute. These names are intended for use in the method signature and will not include any aliases.

pydantic model fitrequest.method_models.FlattenedModelSignature[source]#

Bases: BaseModel

Represents flattened model signatures, simplifying nested Pydantic models into straightforward method signatures.

This class flattens model structures to create simple signatures that are easy to handle with command-line tools. However, it has limitations: it does not support complex signatures involving unions (Model | dict | None) or lists (list[Model]).

Fields:
field model: type[BaseModel] [Required]#
alias_of(attr_name: str) str[source]#

Return the alias for the specified attribute name. If no alias is found, return the original name.

nested_signatures(prefix: str, alias_prefix: str) list[AttrSignature][source]#

Update the names of attributes by appending the specified prefix, indicating this model represents a nested structure within another model.

value_of(attr_name: str, value: Any) Any[source]#

If the provided value type is FieldInfo, return the value generated from that class, which is configured using either the default or default_factory field.

property attr_signatures: list[AttrSignature]#

Creates a flattened representation of the model’s attributes suitable for fitrequest method signatures. The returned list is ordered with positional arguments (args) first, followed by keyword arguments (kwargs), following Python method signature conventions. If use_alias is enabled, the Pydantic alias specified in Field(alias=<alias>) will be used instead of the attribute name.

property attr_signatures_dict: dict[str, AttrSignature]#

Similar to attr_signatures, but organized in a dictionary where the keys are the attribute names.

property params_varnames: set[str]#

Return the names of all flattened attributes. These names are intended for the params field of the httpx request. When provided, they will use the alias instead of the attribute name.

property signature: list[str]#

Returns a flattened list of signatures for all attributes of the model. These names are intended for use in the method signature and will not include any aliases.

property signature_varnames: set[str]#

Return the names of all flattened attributes. These names are intended for the generated method signature, where aliases are ignored.