Utils#

fitrequest.utils.extract_method_params(method: Callable, params: dict) dict[source]#

Return the parameters used in ‘method’ found in ‘params’.

fitrequest.utils.string_varnames(jinja_env: Environment, template: str) list[str][source]#

Extract and sort named variables from the given Jinja2 template by their position in the template.

This function parses the provided Jinja2 template to identify any undeclared variables. It then determines the starting position of each variable within the template and returns a sorted list of these variables based on their positions.

fitrequest.utils.format_url(url: str) str[source]#

Format url to remove redundant / character.

fitrequest.utils.extract_url_params(url: str | None) tuple[str | None, dict][source]#

Extract url parameters and return the base url and it’s parameters as dict.

fitrequest.utils.is_basemodel_subclass(obj: Any) bool[source]#

Return True if the provided object is a subclass of pydantic.BaseModel.

fitrequest.utils.check_reserved_names(names: list[str]) list[str][source]#

Raises an error if a reserved name is used as an endpoint variable or request parameter in the generated method. Otherwise returns the provided names.

fitrequest.utils.reserved_httpx_names = {'auth', 'content', 'cookies', 'data', 'files', 'follow_redirects', 'headers', 'json', 'method', 'params', 'proxy', 'timeout', 'trust_env', 'url', 'verify'}#

Reserved httpx keywords that cannot be used as endpoint variables or URL parameters.

fitrequest.utils.reserved_fitrequest_names = {'args', 'filepath', 'kwargs', 'raise_for_status'}#

Reserved fitrequest keywords that cannot be used as endpoint variables or URL parameters.