asyncutils._internal.patch¶
Utilities to patch various things, from function signatures to annoying warnings emitted by asyncio and python itself.
Attributes¶
The signature of |
Functions¶
|
Equivalent to |
|
|
|
|
|
|
Silence instances of |
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.classmethodobjects, though not callable, are supported.Aclsparameter (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), wheresignaturelooks like the portion of a functiondeclaration within the parentheses opening to the right of the function name.Iffollow_wrappedisTrue, 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 unpredictablebehaviour 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.Aselfparameter (positional-only) is automatically prepended to each of the passed signatures.
- asyncutils._internal.patch.patch_unawaited_coroutine_warnings() None[source]¶
Silence instances of
RuntimeWarningemitted 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 topatch_method_signatures().