spyder.api.utils#
API utilities.
Functions
|
Decorator to mark abstract attributes. |
|
Get the attribute values for the class enumerations used in our API. |
Classes
|
Metaclass to mark abstract classes. |
Dummy class to mark abstract attributes. |
|
|
Utility class used to represent a prefixed string tuple. |
|
Utility class to store and iterate over prefixed string tuples. |
|
Decorator to declare class constants as properties that require additional computation. |
- spyder.api.utils.get_class_values(cls)[source]#
Get the attribute values for the class enumerations used in our API.
Idea from: https://stackoverflow.com/a/17249228/438386
- class spyder.api.utils.PrefixNode(path=None)[source]#
Bases:
objectUtility class used to represent a prefixed string tuple.
- class spyder.api.utils.PrefixedTuple(path=None)[source]#
Bases:
PrefixNodeUtility class to store and iterate over prefixed string tuples.
- class spyder.api.utils.classproperty(fget=None, fset=None, fdel=None, doc=None)[source]#
Bases:
propertyDecorator to declare class constants as properties that require additional computation.
Taken from: https://stackoverflow.com/a/7864317/438386
- class spyder.api.utils.DummyAttribute[source]#
Bases:
objectDummy class to mark abstract attributes.
- spyder.api.utils.abstract_attribute(obj: Callable[[_P], _T] | DummyAttribute | None = None) _T[source]#
Decorator to mark abstract attributes. Must be used in conjunction with the ABCMeta metaclass.
- class spyder.api.utils.ABCMeta(name, bases, namespace, /, **kwargs)[source]#
Bases:
ABCMetaMetaclass to mark abstract classes.
Adds support for abstract attributes. If a class has abstract attributes and is instantiated, a NotImplementedError is raised.
Usage#
class MyABC(metaclass=ABCMeta): @abstract_attribute def my_abstract_attribute(self): pass class MyClassOK(MyABC): def __init__(self): self.my_abstract_attribute = 1 class MyClassNotOK(MyABC): pass
- raises NotImplementedError:
When it’s not possible to instantiate an abstract class with abstract attributes.