Skip to content

Commit 1962601

Browse files
committed
add utils.copy_doc
1 parent 72bd57c commit 1962601

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

flogin/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging.handlers
44
from functools import _make_key as make_cached_key
55
from inspect import isasyncgen, iscoroutine
6+
from inspect import signature as _signature
67
from typing import (
78
TYPE_CHECKING,
89
Any,
@@ -41,6 +42,13 @@ def __get__(self, instance, owner):
4142

4243
__all__ = ("setup_logging", "coro_or_gen", "MISSING", "cached_property", "cached_coro")
4344

45+
def copy_doc(original: Callable[..., Any]) -> Callable[[T], T]:
46+
def decorator(overridden: T) -> T:
47+
overridden.__doc__ = original.__doc__
48+
overridden.__signature__ = _signature(original) # type: ignore
49+
return overridden
50+
51+
return decorator
4452

4553
class _MissingSentinel:
4654
"""A type safe sentinel used in the library to represent something as missing. Used to distinguish from ``None`` values."""

0 commit comments

Comments
 (0)