asyncutils._internal.patch

Utilities to patch various things, from function signatures to annoying warnings emitted by asyncio and python itself.

Attributes

xsig

The signature of __exit__() and __aexit__() as a signature-patcher-compatible string. You would usually only pass this to patch_method_signatures().

Functions

patch_aio_logs(→ None)

Equivalent to logging.getLogger('asyncio').disabled = True.

patch_classmethod_signatures(→ None)

patch_function_signatures(→ None)

patch_method_signatures(→ None)

patch_unawaited_coroutine_warnings(→ None)

Silence instances of RuntimeWarning emitted when an unawaited coroutine is garbage collected.

Module Contents

asyncutils._internal.patch.patch_aio_logs() None[source]

Equivalent to logging.getLogger('asyncio').disabled = True.

asyncutils._internal.patch.patch_classmethod_signatures(*to_patch: asyncutils._internal.types.SigPatcherArg, follow_wrapped: bool = ...) None
patch_function_signatures(), but for class methods.
classmethod objects, though not callable, are supported.
A cls parameter (positional-only) is automatically prepended to each of the passed signatures.
asyncutils._internal.patch.patch_function_signatures(*to_patch: asyncutils._internal.types.SigPatcherArg, follow_wrapped: bool = ...) None
Hide the original signature of functions defined in the top level of a (sub-)module with new signatures.
Each positional argument is a tuple of the form (target_func, signature), where signature looks like the portion of a function
declaration within the parentheses opening to the right of the function name.
If follow_wrapped is True, the original signature is taken from the first wrapped function with a __text_signature__
attribute or the innermost function instead of the wrapper, if applicable. Wrapped functions are found using __func__
and __wrapped__, and it is assumed in the implementation that every level only has one of those, otherwise unpredictable
behaviour may arise.
Useful when, for example, dependency injection, unrepresentable sentinels, mutable defaults and other arity shenanigans are used.
asyncutils._internal.patch.patch_method_signatures(*to_patch: asyncutils._internal.types.SigPatcherArg, follow_wrapped: bool = ...) None
patch_function_signatures(), but for instance methods.
A self parameter (positional-only) is automatically prepended to each of the passed signatures.
asyncutils._internal.patch.patch_unawaited_coroutine_warnings() None[source]

Silence instances of RuntimeWarning emitted when an unawaited coroutine is garbage collected.

asyncutils._internal.patch.xsig: Final[str]

The signature of __exit__() and __aexit__() as a signature-patcher-compatible string. You would usually only pass this to patch_method_signatures().