Useful metamagic classes, such as async ABCs.
Functions
make_proxy (name: str) |
Makes a proxy object for magic methods. |
proxy_to_getattr (*magic_methods: str) |
Proxies a method to to __getattr__ when it would not be normally proxied. |
Classes
AsyncABC |
|
AsyncABCMeta (name, bases, methods) |
Metaclass that gives all of the features of an abstract base class, but additionally enforces coroutine correctness on subclasses. |
AsyncInstanceType (name, bases, methods) |
Metaclass that allows for asynchronous instance initialization and the __init__() method to be defined as a coroutine. |
AsyncObject |
asyncqlio.meta.
proxy_to_getattr
(*magic_methods: str)[source]¶Proxies a method to to __getattr__
when it would not be normally proxied.
This is used for magic methods that are slot loaded (__setattr__
etc.)
Parameters: | magic_methods – The magic methods to proxy to getattr. |
---|
asyncqlio.meta.
AsyncABCMeta
(name, bases, methods)[source]¶Bases: abc.ABCMeta
Metaclass that gives all of the features of an abstract base class, but additionally enforces coroutine correctness on subclasses. If any method is defined as a coroutine in a parent, it must also be defined as a coroutine in any child.
mro
() → list¶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.
asyncqlio.meta.
AsyncInstanceType
(name, bases, methods)[source]¶Bases: asyncqlio.meta.AsyncABCMeta
Metaclass that allows for asynchronous instance initialization and the __init__() method to be defined as a coroutine. Usage: class Spam(metaclass=AsyncInstanceType):
- async def __init__(self, x, y):
- self.x = x self.y = y
mro
() → list¶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.