Source code for asyncutils._internal.patch

[docs] 1def patch_aio_logs(): __import__('logging').getLogger('asyncio').disabled = True
[docs] 2def patch_unawaited_coroutine_warnings(): __import__('warnings').filterwarnings('ignore', "coroutine '.*' was never awaited", RuntimeWarning)
3def _(t, d, a='__text_signature__', u='<unrepresentable>', c=('__wrapped__', '__func__')): 4 def patch(*I, follow_wrapped=True): 5 m = {} 6 for k, v in I: 7 f = True 8 if follow_wrapped: 9 while not (hasattr(k, a) or (i := id(k)) in m): m[i], k, f = k, getattr(k, c[f], k), not f # noqa: PLW2901 10 setattr(k, a, t%v.format(u) if v else d) 11 return patch 12patch_function_signatures, patch_method_signatures, patch_classmethod_signatures = map(_, ('(%s)', '($self, %s)', '($cls, %s)'), ('()', '($self)', '($cls)')) 13xsig = 'exc_typ, exc_val, exc_tb, /' 14del _