casys.visualization.schemas

Casys plot’s related schemas.

Functions

register_casys_plot_methods()

Register all CasysPlot methods' schema.

check_tuple(values, name, message)

Check the validity of the provided tuple.

Classes

AddColorBarSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_color_bar method's parameters.

AddEventSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_event method's parameters.

AddHistBarSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_hist_bar method's parameters.

AddPlotSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_plot method's parameters.

AddStatBarSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_stat_bar method's parameters.

AddStatGraphSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_stat_graph method's parameters.

AddTicksSpaceSchema(*[, only, exclude, ...])

Marshmallow schema for the add_ticks_space method's parameters.

AddWatermarkSchema(*[, only, exclude, many, ...])

Marshmallow schema for the add_watermark method's parameters.

CasysPlotMethodBaseSchema(*[, only, ...])

Base schema for the CasysPlot object methods.

CasysPlotMethodGenericSchema

alias of RegistryGenericSchema

CasysPlotSchema(*[, only, exclude, many, ...])

Marshmallow schema for the CasysPlot class.

FeatureParamsSchema(*[, only, exclude, ...])

Marshmallow schema for the FeatureParams class.

LoadSchema

alias of _MethodSchema

SaveFigureSchema(*[, only, exclude, many, ...])

Marshmallow schema for the save_figure method's parameters.

SetTicksSchema(*[, only, exclude, many, ...])

Marshmallow schema for the set_ticks method's parameters.

ShowiSchema(*[, only, exclude, many, ...])

Marshmallow schema for the showi method's parameters.

ShowSchema(*[, only, exclude, many, ...])

Marshmallow schema for the show method's parameters.

StoreSchema

alias of _MethodSchema

AxisTypeField(*[, load_default, missing, ...])

Marshmallow AxisType field.

PositionField(*[, load_default, missing, ...])

Marshmallow Position field.

TicksSpaceSchema(*[, only, exclude, many, ...])

Schema representing a Tuple (Position, float).

SizeField(*[, load_default, missing, ...])

Marshmallow field representing size (list of two values).

LimitsField(*[, load_default, missing, ...])

Marshmallow field representing limits (list of two values).

ElementTypeField(*[, load_default, missing, ...])

Marshmallow ElementType field.

TargetAxisTypeField(*[, load_default, ...])

Marshmallow TargetAxisType field.

ColorMapField(*[, load_default, missing, ...])

Marshmallow field for the matplotlib class.

CasysEventBaseSchema(*[, only, exclude, ...])

Marshmallow schema for the CasysEvent class.

CasysEventGenericSchema

alias of RegistryGenericSchema

RangeEventSchema(*[, only, exclude, many, ...])

Marshmallow schema for the RangeEvent class.

SimpleEventSchema(*[, only, exclude, many, ...])

Marshmallow schema for the SimpleEvent class.

AxeParamsDictValueSchema(*[, only, exclude, ...])

Marshmallow schema for the CyclePassFormatter class.

AxeParamsSchema(*[, only, exclude, many, ...])

Marshmallow schema for the AxeParams class.

AxeParamsValueGenericSchema(**kwargs)

Generic schema for AxeParams values.

CyclePassFormatterSchema(*[, only, exclude, ...])

Marshmallow schema for the CyclePassFormatter class.

DataParamsSchema(*[, only, exclude, many, ...])

Marshmallow schema for the DataParams class.

GridParamsSchema(*[, only, exclude, many, ...])

Marshmallow schema for the GridParams class.

PlotParamsSchema(*[, only, exclude, many, ...])

Marshmallow schema for the PlotParams class.

TextParamsSchema(*[, only, exclude, many, ...])

Marshmallow schema for the TextParams class.

WatermarkParamsSchema(*[, only, exclude, ...])

Marshmallow schema for the WatermarkParams class.

PlotTemplateNameSchema(*[, only, exclude, ...])

Marshmallow schema for the PlotTemplate represented by their names.

PlotTemplateSchema(*[, only, exclude, many, ...])

Marshmallow schema for the PlotParams class.

PlotTemplateSchemaBaseSchema

alias of RegistryBaseSchema

PlotTemplateSchemaGenericSchema(**kwargs)

Generic schema for for the PlotTemplate object.

TemplateManagerSchema(*[, only, exclude, ...])

Marshmallow schema base class for simple classes.

class casys.visualization.schemas.AddColorBarSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_color_bar method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddEventSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_event method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddHistBarSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_hist_bar method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddPlotSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_plot method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddStatBarSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_stat_bar method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddStatGraphSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_stat_graph method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddTicksSpaceSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_ticks_space method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AddWatermarkSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the add_watermark method’s parameters.

Parameters:
class Meta

Bases: object

unknown = 'include'
OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AxeParamsDictValueSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: RegistryBaseSchema

Marshmallow schema for the CyclePassFormatter class.

Parameters:
class Meta

Bases: object

unknown = 'include'
OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AxeParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the AxeParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AxeParamsValueGenericSchema(**kwargs)

Bases: RegistryGenericSchema

Generic schema for AxeParams values.

class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.AxisTypeField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: BaseEnumField

Marshmallow AxisType field.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.visualization.schemas.CasysEventBaseSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: RegistryBaseSchema

Marshmallow schema for the CasysEvent class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

casys.visualization.schemas.CasysEventGenericSchema

alias of RegistryGenericSchema

class casys.visualization.schemas.CasysPlotMethodBaseSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: RegistryBaseSchema

Base schema for the CasysPlot object methods.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

casys.visualization.schemas.CasysPlotMethodGenericSchema

alias of RegistryGenericSchema

class casys.visualization.schemas.CasysPlotSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the CasysPlot class.

Parameters:
class Meta

Bases: object

unknown = 'include'
OPTIONS_CLASS

alias of SchemaOpts

STORED_PLOTS = {}
TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.ColorMapField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: Field

Marshmallow field for the matplotlib class.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.visualization.schemas.CyclePassFormatterSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: RegistryBaseSchema

Marshmallow schema for the CyclePassFormatter class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.DataParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the DataParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.ElementTypeField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: BaseEnumField

Marshmallow ElementType field.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.visualization.schemas.FeatureParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the FeatureParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.GridParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the GridParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.LimitsField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: Field

Marshmallow field representing limits (list of two values).

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

casys.visualization.schemas.LoadSchema

alias of _MethodSchema

class casys.visualization.schemas.PlotParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the PlotParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.PlotTemplateNameSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: RegistryBaseSchema

Marshmallow schema for the PlotTemplate represented by their names.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.PlotTemplateSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: RegistryBaseSchema

Marshmallow schema for the PlotParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

casys.visualization.schemas.PlotTemplateSchemaBaseSchema

alias of RegistryBaseSchema

class casys.visualization.schemas.PlotTemplateSchemaGenericSchema(**kwargs)

Bases: RegistryGenericSchema

Generic schema for for the PlotTemplate object.

class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.PositionField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: BaseEnumField

Marshmallow Position field.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.visualization.schemas.RangeEventSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysEventBaseSchema

Marshmallow schema for the RangeEvent class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dump_fields: dict[str, Field]
dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

exclude: set[typing.Any] | typing.MutableSet[typing.Any]
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

load_fields: dict[str, Field]
loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.SaveFigureSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the save_figure method’s parameters.

Parameters:
class Meta

Bases: object

unknown = 'include'
OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dump_fields: dict[str, Field]
dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

exclude: set[typing.Any] | typing.MutableSet[typing.Any]
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

load_fields: dict[str, Field]
loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.SetTicksSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the set_ticks method’s parameters.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dump_fields: dict[str, Field]
dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

exclude: set[typing.Any] | typing.MutableSet[typing.Any]
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

load_fields: dict[str, Field]
loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.ShowSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the show method’s parameters.

Parameters:
class Meta

Bases: object

unknown = 'include'
OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dump_fields: dict[str, Field]
dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

exclude: set[typing.Any] | typing.MutableSet[typing.Any]
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

load_fields: dict[str, Field]
loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.ShowiSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysPlotMethodBaseSchema

Marshmallow schema for the showi method’s parameters.

Parameters:
class Meta

Bases: object

unknown = 'include'
OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dump_fields: dict[str, Field]
dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

exclude: set[typing.Any] | typing.MutableSet[typing.Any]
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

load_fields: dict[str, Field]
loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.SimpleEventSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: CasysEventBaseSchema

Marshmallow schema for the SimpleEvent class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
classmethod clear_registry()

Clear everything from this schema’s registry.

property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dump_fields: dict[str, Field]
dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

exclude: set[typing.Any] | typing.MutableSet[typing.Any]
fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_class(name: str) type[RegistryBaseSchema]

Return the registered class associated with the provided name.

Parameters:

name (str) – Identifier of the schema.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

classmethod get_model_schema(model: type) type[RegistryBaseSchema]

Return the registered class associated with the provided model.

Parameters:

model (type) – Identifier of the model.

Return type:

type[RegistryBaseSchema]

Returns:

Corresponding schema class.

classmethod get_type()

Schema’s ID.

Return type:

str

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

classmethod has_class(name: str) bool

Test if the provided name is registered.

Parameters:

name (str) – Name of the class.

Return type:

bool

Returns:

True if a class with this name is registered, False otherwise.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

load_fields: dict[str, Field]
loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
classmethod register()

Register the current class.

classmethod register_schema(schema, exception)

Register the provided schema.

Parameters:
classmethod registry()

Returns a copy of the registry.

Return type:

dict[str, type[RegistryAbstractSchema]]

classmethod remove_registry(name)
Parameters:

name (str)

set_class

alias of OrderedSet

classmethod update_registry(schema)

Update current registry with the provided one. An error is raised if the same name is used twice.

Parameters:

schema (type[RegistryAbstractSchema]) – Schemas to register.

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.SizeField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: Field

Marshmallow field representing size (list of two values).

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

casys.visualization.schemas.StoreSchema

alias of _MethodSchema

class casys.visualization.schemas.TargetAxisTypeField(*, load_default=<marshmallow.missing>, missing=<marshmallow.missing>, dump_default=<marshmallow.missing>, default=<marshmallow.missing>, data_key=None, attribute=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, error_messages=None, metadata=None, **additional_metadata)

Bases: BaseEnumField

Marshmallow TargetAxisType field.

Parameters:
property context: dict | None

The context dictionary for the parent Schema <marshmallow.Schema>.

property default
default_error_messages: dict[str, str] = {'null': 'Field may not be null.', 'required': 'Missing data for required field.', 'validator_failed': 'Invalid value.'}

Default error messages for various kinds of errors. The keys in this dictionary are passed to Field.make_error. The values are error messages passed to marshmallow.exceptions.ValidationError.

deserialize(value, attr=None, data=None, **kwargs)

Deserialize value.

Parameters:
  • value (Any) – The value to deserialize.

  • attr (str | None) – The attribute/key in data to deserialize.

  • data (Optional[Mapping[str, Any]]) – The raw input data passed to Schema.load <marshmallow.Schema.load>.

  • kwargs – Field-specific keyword arguments.

Raises:

ValidationError – If an invalid value is passed or if a required value is missing.

fail(key, **kwargs)

Helper method that raises a ValidationError with an error message from self.error_messages.

Deprecated since version 3.0.0: Use make_error <marshmallow.fields.Field.make_error> instead.

Parameters:

key (str)

get_value(obj, attr, accessor=None, default=<marshmallow.missing>)

Return the value for a given key from an object.

Parameters:
  • obj (Any) – The object to get the value from.

  • attr (str) – The attribute/key in obj to get the value from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – A callable used to retrieve the value of attr from the object obj. Defaults to marshmallow.utils.get_value.

  • default (Any)

make_error(key, **kwargs)

Helper method to make a ValidationError with an error message from self.error_messages.

Parameters:

key (str)

Return type:

ValidationError

property missing
serialize(attr, obj, accessor=None, **kwargs)

Pulls the value for the given key from the object, applies the field’s formatting and returns the result.

Parameters:
  • attr (str) – The attribute/key to get from the object.

  • obj (Any) – The object to access the attribute/key from.

  • accessor (Optional[Callable[[Any, str, Any], Any]]) – Function used to access values from obj.

  • kwargs – Field-specific keyword arguments.

class casys.visualization.schemas.TemplateManagerSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema base class for simple classes.

Model instantiation can be disabled by setting the SCHEMA_DISABLE_MODEL context variable to True.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.TextParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the TextParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.TicksSpaceSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Schema representing a Tuple (Position, float).

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

class casys.visualization.schemas.WatermarkParamsSchema(*, only=None, exclude=(), many=None, context=None, load_only=(), dump_only=(), partial=None, unknown=None)

Bases: BaseSchema

Marshmallow schema for the WatermarkParams class.

Parameters:
class Meta

Bases: object

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Opts):
        additional = True  # Incompatible types in assignment

Removed in version 3.0.0b7: Remove strict.

Added in version 3.0.0b12: Add unknown.

Changed in version 3.0.0b17: Rename dateformat to datetimeformat.

Added in version 3.9.0: Add timeformat.

Changed in version 3.26.0: Deprecate ordered. Field order is preserved by default.

additional: ClassVar[tuple[str, ...] | list[str]]

Fields to include in addition to the explicitly declared fields. additional <marshmallow.Schema.Meta.additional> and fields <marshmallow.Schema.Meta.fields> are mutually-exclusive options.

dateformat: ClassVar[str]

Default format for Date <marshmallow.fields.Date> fields.

datetimeformat: ClassVar[str]

Default format for DateTime <marshmallow.fields.DateTime> fields.

dump_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

exclude: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude in the serialized result. Nested fields can be represented with dot delimiters.

fields: ClassVar[tuple[str, ...] | list[str]]

Fields to include in the (de)serialized result

include: ClassVar[dict[str, Field]]

Dictionary of additional fields to include in the schema. It is usually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords.

index_errors: ClassVar[bool]

If True, errors dictionaries will include the index of invalid items in a collection.

load_only: ClassVar[tuple[str, ...] | list[str]]

Fields to exclude from serialized results

many: ClassVar[bool]

Whether data should be (de)serialized as a collection by default.

ordered: ClassVar[bool]

If True, Schema.dump <marshmallow.Schema.dump> is a collections.OrderedDict.

register: ClassVar[bool]

Whether to register the Schema <marshmallow.Schema> with marshmallow’s internal class registry. Must be True if you intend to refer to this Schema <marshmallow.Schema> by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.

render_module: Any

Module to use for loads <marshmallow.Schema.loads> and dumps <marshmallow.Schema.dumps>. Defaults to json from the standard library.

timeformat: ClassVar[str]

Default format for Time <marshmallow.fields.Time> fields.

unknown: ClassVar[str]

Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

OPTIONS_CLASS

alias of SchemaOpts

TYPE_MAPPING: dict[type, type[Field]] = {<class 'bool'>: <class 'marshmallow.fields.Boolean'>, <class 'bytes'>: <class 'marshmallow.fields.String'>, <class 'datetime.date'>: <class 'marshmallow.fields.Date'>, <class 'datetime.datetime'>: <class 'marshmallow.fields.DateTime'>, <class 'datetime.time'>: <class 'marshmallow.fields.Time'>, <class 'datetime.timedelta'>: <class 'marshmallow.fields.TimeDelta'>, <class 'decimal.Decimal'>: <class 'marshmallow.fields.Decimal'>, <class 'float'>: <class 'marshmallow.fields.Float'>, <class 'int'>: <class 'marshmallow.fields.Integer'>, <class 'list'>: <class 'marshmallow.fields.Raw'>, <class 'set'>: <class 'marshmallow.fields.Raw'>, <class 'str'>: <class 'marshmallow.fields.String'>, <class 'tuple'>: <class 'marshmallow.fields.Raw'>, <class 'uuid.UUID'>: <class 'marshmallow.fields.UUID'>}
property dict_class: type[dict]

dict type to return when serializing.

dump(obj, *, many=None)

Serialize an object to native Python data types according to this Schema’s fields.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

Serialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.

dumps(obj, *args, many=None, **kwargs)

Same as dump(), except return a JSON-encoded string.

Parameters:
  • obj (Any) – The object to serialize.

  • many (bool | None) – Whether to serialize obj as a collection. If None, the value for self.many is used.

Returns:

A json string

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the serialized data rather than a (data, errors) duple. A ValidationError is raised if obj is invalid.

error_messages: dict[str, str] = {}

Overrides for default schema-level error messages

fields: dict[str, Field]

Dictionary mapping field_names -> Field objects

classmethod from_dict(fields, *, name='GeneratedSchema')

Generate a Schema <marshmallow.Schema> class given a dictionary of fields.

from marshmallow import Schema, fields

PersonSchema = Schema.from_dict({"name": fields.Str()})
print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}

Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.

Parameters:
  • fields (dict[str, Field]) – Dictionary mapping field names to field instances.

  • name (str) – Optional name for the class, which will appear in the repr for the class.

Return type:

type[Schema]

Added in version 3.0.0.

get_attribute(obj, attr, default)

Defines how to pull values from an object to serialize.

Changed in version 3.0.0a1: Changed position of obj and attr.

Parameters:
classmethod get_model()

Return the model associated to this schema.

Return type:

type[TypeVar(T)] | None

Returns:

Model associated to this schema.

handle_error(error, data, *, many, **kwargs)

Custom error handler function for the schema.

Parameters:
  • error (ValidationError) – The ValidationError raised during (de)serialization.

  • data (Any) – The original input data.

  • many (bool) – Value of many on dump or load.

  • partial – Value of partial on load.

Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.

load(data, *, many=None, partial=None, unknown=None)

Deserialize a data structure to an object defined by this Schema’s fields.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to deserialize.

  • many (bool | None) – Whether to deserialize data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

loads(json_data, *, many=None, partial=None, unknown=None, **kwargs)

Same as load(), except it uses marshmallow.Schema.Meta.render_module to deserialize the passed string before passing data to load().

Parameters:
  • json_data (str | bytes | bytearray) – A string of the data to deserialize.

  • many (bool | None) – Whether to deserialize obj as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

  • unknown (str | None) – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.

Returns:

Deserialized data

Added in version 1.0.0.

Changed in version 3.0.0b7: This method returns the deserialized data rather than a (data, errors) duple. A ValidationError is raised if invalid data are passed.

make_object(data, **_)
on_bind_field(field_name, field_obj)

Hook to modify a field when it is bound to the Schema <marshmallow.Schema>.

No-op by default.

Parameters:
  • field_name (str)

  • field_obj (Field)

Return type:

None

opts: typing.Any = <marshmallow.schema.SchemaOpts object>
post_dump(data, original_data, **_)
pre_dump(data, **_)
pre_load(data, **_)
set_class

alias of OrderedSet

validate(data, *, many=None, partial=None)

Validate data against the schema, returning a dictionary of validation errors.

Parameters:
  • data (Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]) – The data to validate.

  • many (bool | None) – Whether to validate data as a collection. If None, the value for self.many is used.

  • partial (Union[bool, Sequence[str], AbstractSet[str], None]) – Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.

Return type:

dict[str, list[str]]

Returns:

A dictionary of validation errors.

Added in version 1.1.0.

casys.visualization.schemas.check_tuple(values, name, message)

Check the validity of the provided tuple.

Parameters:
  • values (tuple[Any, Any]) – Tuple’s values to check.

  • name (str) – Name of the tuple’s parameter.

  • message (str) – Error message used to identify the tuple’s type.

casys.visualization.schemas.register_casys_plot_methods()

Register all CasysPlot methods’ schema.