Useful metamagic classes, such as async ABCs.
Functions
make_proxy (name) |
Makes a proxy object for magic methods. |
proxy_to_getattr (*magic_methods) |
Proxies a method to to __getattr__ when it would not be normally proxied. |
typeproperty (func) |
Marks a function as a type property. |
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 |
|
TypeProperty (fget) |
A property on a type. |
asyncqlio.meta.
proxy_to_getattr
(*magic_methods)[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 (str ) – The magic methods to proxy to getattr. |
---|
asyncqlio.meta.
TypeProperty
(fget)[source]¶Bases: object
A property on a type.
Parameters: | fget – The function to call on getting the property. |
---|
asyncqlio.meta.
typeproperty
(func)[source]¶Marks a function as a type property.
Return type: | TypeProperty |
---|
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.
class Spam(metaclass=AsyncInstanceType):
async def __init__(self, x, y):
self.x = x
self.y = y
async def main():
s = await Spam(2, 3)
...
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.