API reference


Tools for deserialization


  • resolve forward declarations in dataclass signatures
  • auto namedtuple registry
class valuable.load.Registry[source]

Interface for a loader registry. Any callable with signature Type[T] -> Loader[T] implements it.

class valuable.load.Loader[source]

Interface for loaders (deserializers). Any callable with the signature Any -> T implements Loader[T]


loads an object of a particular type from any data

Return type:~T
class valuable.load.CombinableRegistry[source]

base class for registries which may be combined

any callable implemeting the signature (t.Type[T], Registry) -> Loader[T] is combinable

also provides __or__ as a mixin method

class valuable.load.PrimitiveRegistry(registry={})[source]

a registry of primitive (i.e. non-nested) loaders

class valuable.load.GenericRegistry(registry={})[source]

registry for generic types. for example List.

These types must have __origin__ and __args__ attributes

class valuable.load.AutoDataclassRegistry[source]

registry which creates dataclass loaders on-the-fly

valuable.load.create_dataclass_loader(cls, registry, field_getters)[source]

create a loader for a dataclass type

valuable.load.list_loader(subloaders, value)[source]

loader for the List generic

valuable.load.set_loader(subloaders, value)[source]

loader for the Set generic

exception valuable.load.UnsupportedType[source]

indicates the registry does not have a loader for the given type

class valuable.load.DataclassRegistry(confs)[source]

registry for dataclasses

class valuable.load.lookup_defaults(lookup: typing.Callable[[typing.Any], T], default: T)[source]

wrap a lookup function with a default if lookup fails

valuable.load.get_optional_loader(cls, main)[source]

a combinable registry for optional types

Return type:Loader[~T]

naive parser for ISO8061 datetime strings,

Parameters:dtstring (str) –

the datetime as string in one of two formats:

  • 2017-11-20T07:16:29+0000
  • 2017-11-20T07:16:29Z
Return type:datetime


shortcuts for working with XML data


shortcut making an XML element getter

Return type:Callable[[Element], Element]
valuable.xml.textgetter(path, *, default=<class 'valuable.utils.NO_DEFAULT'>, strip=False)[source]

shortcut for making an XML element text getter

Return type:Callable[[Element], Union[str, ~T]]


Miscellaneous tools, boilerplate, and shortcuts

class valuable.utils.NO_DEFAULT[source]

sentinel for no default

class valuable.utils.compose(*funcs: typing.Callable)[source]

compose a function from a chain of functions

Parameters:*funcs – callables to compose



identity function, returns input unmodified