API Documentation¶
Module lockup¶
Immutable module class and namespace factory.
- class lockup.Class(name, bases, namespace)¶
Bases:
typeProduces classes which have immutable attributes.
Non-public attributes of each class are concealed from
dir().Note
Only class attributes are immutable. Instances of immutable classes will have mutable attributes without additional intervention beyond the scope of this package.
- mro()¶
Return a type’s method resolution order.
- class lockup.NamespaceClass(name, bases, namespace)¶
Bases:
lockup.ClassProduces namespace classes which have immutable attributes.
Each produced namespace is a unique class, which cannot be instantiated.
Non-public attributes of each class are concealed from
dir().Warning
Although most descriptor attributes will be inert on a class,
types.DynamicClassAttribute()and similar, may trigger attribute errors when accessed. However, these are a fairly rare case and are probably not needed on namespaces, in general.- mro()¶
Return a type’s method resolution order.
- lockup.create_namespace(**nomargs)¶
Creates immutable namespaces from nominative arguments.
- class lockup.Module(name, doc=None)¶
Bases:
moduleModule whose attributes are immutable except during module definition.
Can replace the
__class__attribute on an existing module.Non-public attributes of the module are concealed from
dir(). Also, a copy of the module dictionary is returned when the__dict__attribute is accessed; this is done to remove a backdoor by which attributes could be mutated.Note
Copies of the module dictionary are mutable so as to not violate the internal expectations of Python as well as important packages, such as
doctest. Ideally, these would be immutable, but cannot be as of this writing.
- lockup.reclassify_module(module)¶
Assigns
Moduleas class for module.Takes either a module object or the name of a module in
sys.modules. If the module has already been reclassified, then nothing is done (i.e., the operation is idempotent).
Module lockup.exceptions¶
All exceptions raised by this package have a common base:
Exception0.
- exception lockup.exceptions.Exception0(*things, tags=None, **sundry)¶
Bases:
BaseExceptionBase for all exceptions in the package.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.FugitiveException(supplement=None)¶
Bases:
lockup.exceptions.InvalidState,RuntimeErrorAlert about fugitive exception intercepted at API boundary.
An fugitive exception is one which is not intended to be reported across the package API boundary. Fugitive exceptions include Python built-ins, such as
IndexError.- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.ImpermissibleAttributeOperation(*things, tags=None, **sundry)¶
Bases:
lockup.exceptions.ImpermissibleOperation,AttributeErrorComplaint about impermissible attribute operation.
Cannot use
ImpermissibleOperationbecause some packages, such as Sphinx Autodoc, expect anAttributeError.- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.ImpermissibleOperation(*things, tags=None, **sundry)¶
Bases:
lockup.exceptions.InvalidOperation,TypeErrorComplaint about impermissible operation.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.InaccessibleAttribute(*things, tags=None, **sundry)¶
Bases:
lockup.exceptions.InaccessibleEntity,AttributeErrorComplaint about attempt to retrieve inaccessible attribute.
Cannot use
InaccessibleEntitybecause some Python internals expect anAttributeError.- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.InaccessibleEntity(*things, tags=None, **sundry)¶
Bases:
lockup.exceptions.InvalidOperationComplaint about attempt to retrieve inaccessible entity.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.IncorrectData(*things, tags=None, **sundry)¶
Bases:
lockup.exceptions.InvalidOperation,TypeError,ValueErrorComplaint about incorrect data for invocation or operation.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.InvalidOperation(*things, tags=None, **sundry)¶
Bases:
lockup.exceptions.Exception0,ExceptionComplaint about invalid operation.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lockup.exceptions.InvalidState(supplement=None)¶
Bases:
lockup.exceptions.Exception0,ExceptionAlert about invalid internal state in the package.
Owner of problem: maintainers of this package.
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.