MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / __new__

Method __new__

asyncpg/pool.py:48–73  ·  view source on GitHub ↗
(
        mcls,
        name: str,
        bases: tuple[Type[Any], ...],
        dct: dict[str, Any],
        *,
        wrap: bool = False,
    )

Source from the content-addressed store, hash-verified

46class PoolConnectionProxyMeta(type):
47
48 def __new__(
49 mcls,
50 name: str,
51 bases: tuple[Type[Any], ...],
52 dct: dict[str, Any],
53 *,
54 wrap: bool = False,
55 ) -> PoolConnectionProxyMeta:
56 if wrap:
57 for attrname in dir(connection.Connection):
58 if attrname.startswith('_') or attrname in dct:
59 continue
60
61 meth = getattr(connection.Connection, attrname)
62 if not inspect.isfunction(meth):
63 continue
64
65 iscoroutine = inspect.iscoroutinefunction(meth)
66 wrapper = mcls._wrap_connection_method(attrname, iscoroutine)
67 wrapper = functools.update_wrapper(wrapper, meth)
68 dct[attrname] = wrapper
69
70 if '__doc__' not in dct:
71 dct['__doc__'] = connection.Connection.__doc__
72
73 return super().__new__(mcls, name, bases, dct)
74
75 @staticmethod
76 def _wrap_connection_method(

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected