partis.schema_meta.base module#

exception SchemaError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: ModelError

Base of all schema related errors

exception SchemaNameError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when a name error occurs

exception SchemaParseError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when a schema cannot be detected

exception SchemaDetectionError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when a schema cannot be detected

exception SchemaDeclaredError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when a schema’s declared is used before the schema has been defined

exception SchemaDefinitionError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when a schema’s definition is not correctly specified

exception SchemaValidationError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when data could not be validated (encoded/decoded) using schema definition

exception SchemaEvaluationError(msg, loc=None, level=None, ignore_frame=None, *args, **kwargs)[source]#

Bases: SchemaError

Raised when evaluated expression failed to result in a decoded value

class SchemaHint(msg=None, data=None, format=None, loc=None, level=None, hints=None)[source]#

Bases: ModelHint

Base of all schema hints

class Bias(val=None, const=None)[source]#

Bases: object

A metric of how biased (selective) a value is to a schema

This may be interpreted as the number of needed independent binary decisions (questions, or conditional statements) to determine that the value satisfied the schema.

Parameters:
  • val (None | float) – The current/initial bias value

  • const (None | bool) – If True, the bias value is considered to be a constant.

class PresetValue(val, label=None, doc=None)[source]#

Bases: object

A preset value associated with a schema

Parameters:
is_required(val)[source]#
Returns:

bool – True if the value corresponds to being required, likely resulting in an error if no value is supplied.

is_optional(val)[source]#
Returns:

bool – True if the value corresponds to being optional, resulting in a default of None

is_derived(val)[source]#
Returns:

bool – True if the value is to be derived from some other value(s)

is_notset(val)[source]#
Returns:

bool – True if the value corresponds to being not set, or otherwise undefined, including not even None.

is_bool(obj)[source]#

Is a boolean value

is_numeric(obj)[source]#

Is a numeric value

is_string(obj)[source]#

Is a string value

is_sequence(obj)[source]#

Is a sequence value, but not a string

is_mapping(obj)[source]#

Is a mapping value

is_similar_value_type(a, b)[source]#
Returns:

is_similar_value_type (bool) – True if all type_tests return the same for both values

is_schema(obj)[source]#

Is a schema class or schema declared

is_schema_prim(obj)[source]#

Is a schema primitive type

is_schema_declared(obj)[source]#

Is a schema class or schema declared type

is_schema_struct(obj)[source]#

Is a schema class or schema declared type

is_schema_struct_valued(obj)[source]#

Is an instance value of a schema class type

is_evaluated_class(val)[source]#

Is an evaluated class type

is_provider(val)[source]#

Is an evaluated type

is_evaluated(val)[source]#

Is an evaluated type

is_valued_type(val)[source]#
Returns:

is_valued_type (bool) – True if is an instance value of any schema type

any_schema(val, schemas)[source]#

Is the schema any of the list schemas

Parameters:
  • schema (list[object]) – Schema to test

  • schema – Schemas to compare to

is_valued(val)[source]#
Returns:

is_valued (bool) – True if value is completely evaluated