Datatypes

Module containing internal classes used for storing internal data

Exposed classes offer a bit of introspection that can be useful

pheres._datatypes.MISSING = MISSING

Sentinel object used when None cannot be used

class pheres._datatypes.JsonAttr(module: ModuleType, cls_name: str, name: str, py_name: str, type: TypeHint, default: Any = MISSING, is_json_only: Union[_MISSING, bool] = MISSING, *, cls: type = None)

Bases: object

Stores information for a json attribute

Variables
  • name (str) – name of this attribute in JSON

  • py_name (str) – name of this attribute in python

  • type (TypeHint) – type of this attribute

  • is_json_only (Union[_MISSING, bool]) – if this attribute should be only present in JSON

property is_required

Returns True if this attribute is mandatory in JSON

get_default()

Returns the default value of this attribute

The returned value is a copy and is safe to use and modify

class pheres._datatypes.ValueData(type: TypeHint)

Bases: object

Opaque type storing pheres data for jsonable values

Exposed for used with issubclass

class pheres._datatypes.ArrayData(types: tuple)

Bases: object

Opaque type storing pheres data for jsonable arrays

Exposed for used with issubclass

class pheres._datatypes.DictData(type: TypeHint)

Bases: object

Opaque type storing pheres data for jsonable dicts

Exposed for used with issubclass

class pheres._datatypes.ObjectData(attrs: dict[str, JsonAttr])

Bases: object

Opaque type storing pheres data for jsonable objects

Exposed for used with issubclass

class pheres._datatypes.DelayedData(func: Callable[[type], type], kind: JsonableEnum)

Bases: object

Opaque type storing pheres data for jsonable that have been delayed

Exposed for used with issubclass

Variables

kind (pheres._datatypes.JsonableEnum) – What type of jsonable the class will be once decorated (This has not happened yet !)

class pheres._datatypes.UsableDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)

Bases: json.decoder.JSONDecoder

json.JSONDecoder subclass with wrapper methods load() and loads() using itself for the decoder class

classmethod load(*args, **kwargs)

Thin wrapper around json.load that use this class as the default cls argument

classmethod loads(*args, **kwargs)

Thin wrapper around json.loads that use this class as the default cls argument