fqr.objects.utl module

Objects utility functions.

get_enumerations_from_fields(fields: dict[string[snake_case], AnyField[lib.t.Any]]) dict[string[snake_case], tuple[bool | float | int | None | str, ...]]

Return dict containing all enums for object.

Automatically appends None to any enums for an Optional type.

get_fields_for_hash(__fields: dict[string[snake_case], AnyField[lib.t.Any]]) tuple[string[snake_case], ...]

Filter to set of minimum fields required to compute a unique hash for their owner object.

Fields used must be of primitive types, for these purposes: bool | float | int | None | str.

Fields ending in the following will be used [in the following order of precedence]:

  1. '*id' | '*key'

  2. '*name'

For example, for an object with fields 'id_' and '_common_name_', this function would return ('id_', ), as 'id_' takes precedence over '_common_name_'.

If no fields are named in ways that suggest they can be used to determine the uniqueness of the object, all fields will instead be returned.

is_public_field(f: str) bool

Return if field name is public.

is_valid_keyword(f: str) bool

Return if field name is allowed.