API¶
Package accretive
¶
Module accretive
¶
Accretive data structures.
- class accretive.ABCFactory(name: str, bases: tuple[type, ...], namespace: dict[str, ~typing_extensions.Any], *, decorators: ~collections.abc.Iterable[~collections.abc.Callable[[type], type]] = (), docstring: str | None | ~accretive.__.Absent = <accretive.__.Absent object>, **args: ~typing_extensions.Any)¶
Bases:
ABCMeta
Accretive abstract base class factory.
Derived from
type
, this is a metaclass. A metaclass is a class factory class. I.e., it is a class that produces other classes as its instances.Prevents reassignment or deletion of class attributes after they have been assigned. Only assignment of new class attributes is permitted.
- mro()¶
Return a type’s method resolution order.
- register(subclass)¶
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
- class accretive.Class(name: str, bases: tuple[type, ...], namespace: dict[str, ~typing_extensions.Any], *, decorators: ~collections.abc.Iterable[~collections.abc.Callable[[type], type]] = (), docstring: str | None | ~accretive.__.Absent = <accretive.__.Absent object>, **args: ~typing_extensions.Any)¶
Bases:
type
Accretive class factory.
Derived from
type
, this is a metaclass. A metaclass is a class factory class. I.e., it is a class that produces other classes as its instances.Prevents reassignment or deletion of class attributes after they have been assigned. Only assignment of new class attributes is permitted.
- mro()¶
Return a type’s method resolution order.
- class accretive.Dictionary(*iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')])¶
-
Accretive dictionary.
Prevents alteration or removal of dictionary entries after they have been added. Only addition of new dictionary entries is permitted.
Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- copy() Self ¶
Provides fresh copy of dictionary.
- get(key: ~collections.abc.Hashable, default: ~typing_extensions.Any | ~accretive.__.Absent = <accretive.__.Absent object>) Annotated[Any, Doc('Value of entry, if it exists. Else, supplied default value or ``None``.')] ¶
Retrieves entry associated with key, if it exists.
- update(*iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')]) Self ¶
Adds new entries as a batch.
- values() ValuesView[Any] ¶
Provides iterable view over dictionary values.
- class accretive.Module(name, doc=None)¶
Bases:
ModuleType
Accretive modules.
Derived from
types.ModuleType
, this class is suitable for use as a Python module class.Prevents reassignment or deletion of module attributes after they have been assigned. Only assignment of new module attributes is permitted.
- class accretive.Namespace(*iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **attributes: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')])¶
Bases:
Object
Accretive namespaces.
A namespace is an object, whose attributes can be determined from iterables and keyword arguments, at initialization time. The string representation of the namespace object reflects its current instance attributes. Modeled after
types.SimpleNamespace
.Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- class accretive.Object(*posargs: Any, **nomargs: Any)¶
Bases:
object
Accretive objects.
Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- class accretive.ProducerDictionary(producer: Annotated[Callable[[], Any], Doc('Callable which produces values for absent dictionary entries.')], /, *iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')])¶
Bases:
Dictionary
,Generic
[H
,V
]Accretive dictionary with default value for missing entries.
Prevents alteration or removal of dictionary entries after they have been added. Only addition of new dictionary entries is permitted.
When an attempt to access a missing entry is made, then the entry is added with a default value. Modeled after
collections.defaultdict
.Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- copy() Self ¶
Provides fresh copy of dictionary.
- get(key: ~collections.abc.Hashable, default: ~typing_extensions.Any | ~accretive.__.Absent = <accretive.__.Absent object>) Annotated[Any, Doc('Value of entry, if it exists. Else, supplied default value or ``None``.')] ¶
Retrieves entry associated with key, if it exists.
- update(*iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')]) Self ¶
Adds new entries as a batch.
- values() ValuesView[Any] ¶
Provides iterable view over dictionary values.
- class accretive.ProducerValidatorDictionary(producer: Annotated[Callable[[], Any], Doc('Callable which produces values for absent dictionary entries.')], validator: Annotated[Callable[[Hashable, Any], bool], Doc('Callable which validates entries before addition to dictionary.')], /, *iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')])¶
Bases:
Dictionary
,Generic
[H
,V
]Accretive dictionary with defaults and validation.
Prevents alteration or removal of dictionary entries after they have been added. Only addition of new dictionary entries is permitted.
When an attempt to access a missing entry is made, then the entry is added with a default value. Modeled after
collections.defaultdict
.When an attempt to add a new entry is made, then the entry is validated against supplied criteria. If validation fails, then the entry is rejected.
Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- copy() Self ¶
Provides fresh copy of dictionary.
- get(key: ~collections.abc.Hashable, default: ~typing_extensions.Any | ~accretive.__.Absent = <accretive.__.Absent object>) Annotated[Any, Doc('Value of entry, if it exists. Else, supplied default value or ``None``.')] ¶
Retrieves entry associated with key, if it exists.
- update(*iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')]) Self ¶
Adds new entries as a batch.
- values() ValuesView[Any] ¶
Provides iterable view over dictionary values.
- class accretive.ProtocolClass(name: str, bases: tuple[type, ...], namespace: dict[str, ~typing_extensions.Any], *, decorators: ~collections.abc.Iterable[~collections.abc.Callable[[type], type]] = (), docstring: str | None | ~accretive.__.Absent = <accretive.__.Absent object>, **args: ~typing_extensions.Any)¶
Bases:
_ProtocolMeta
Accretive protocol class factory.
Derived from
type
, this is a metaclass. A metaclass is a class factory class. I.e., it is a class that produces other classes as its instances.Prevents reassignment or deletion of class attributes after they have been assigned. Only assignment of new class attributes is permitted.
- mro()¶
Return a type’s method resolution order.
- register(subclass)¶
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
- class accretive.ValidatorDictionary(validator: Annotated[Callable[[Hashable, Any], bool], Doc('Callable which validates entries before addition to dictionary.')], /, *iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')])¶
Bases:
Dictionary
,Generic
[H
,V
]Accretive dictionary with validation of new entries.
Prevents alteration or removal of dictionary entries after they have been added. Only addition of new dictionary entries is permitted.
When an attempt to add a new entry is made, then the entry is validated against supplied criteria. If validation fails, then the entry is rejected.
Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- copy() Self ¶
Provides fresh copy of dictionary.
- get(key: ~collections.abc.Hashable, default: ~typing_extensions.Any | ~accretive.__.Absent = <accretive.__.Absent object>) Annotated[Any, Doc('Value of entry, if it exists. Else, supplied default value or ``None``.')] ¶
Retrieves entry associated with key, if it exists.
- update(*iterables: Annotated[Mapping[Hashable, Any] | Iterable[tuple[Hashable, Any]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[Any, Doc('Zero or more keyword arguments from which to initialize dictionary data.')]) Self ¶
Adds new entries as a batch.
- values() ValuesView[Any] ¶
Provides iterable view over dictionary values.
Module accretive.exceptions
¶
Family of exceptions for package API.
- exception accretive.exceptions.EntryValidationError(key: Hashable, value: Any)¶
Bases:
Omnierror
,ValueError
Attempt to add invalid entry to dictionary.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception accretive.exceptions.IndelibleAttributeError(name: str)¶
Bases:
Omnierror
,AttributeError
,TypeError
Attempt to reassign or delete indelible attribute.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- name¶
attribute name
- obj¶
object
- exception accretive.exceptions.IndelibleEntryError(indicator: Any)¶
-
Attempt to update or remove indelible dictionary entry.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception accretive.exceptions.InvalidOperationError(name: str)¶
Bases:
Omnierror
,RuntimeError
,TypeError
Attempt to perform invalid operation.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception accretive.exceptions.Omnierror¶
Bases:
Omniexception
,Exception
Base for error exceptions raised by package API.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception accretive.exceptions.Omniexception¶
Bases:
InternalObject
,BaseException
Base for all exceptions raised by package API.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
Module accretive.qaliases
¶
Qualified aliases to accretive data structures.
Useful for avoiding namespace collisions from attribute imports.
- accretive.qaliases.AccretiveABCFactory
alias of
ABCFactory
- accretive.qaliases.AccretiveClass
alias of
Class
- accretive.qaliases.AccretiveDictionary
alias of
Dictionary
- accretive.qaliases.AccretiveModule
alias of
Module
- accretive.qaliases.AccretiveNamespace
alias of
Namespace
- accretive.qaliases.AccretiveObject
alias of
Object
- accretive.qaliases.AccretiveProducerDictionary
alias of
ProducerDictionary
- accretive.qaliases.reclassify_modules_as_accretive(attributes: ~collections.abc.Mapping[str, ~typing_extensions.Any], to_class: type[~accretive.modules.Module] = <class 'accretive.modules.Module'>) None
Reclassifies modules in dictionary with custom module type.