function#
+function#
Utils for manipulating functions.
- -exception GlobalNameConflictError[source]# -
- Bases: +exception GlobalNameConflictError[source]# +- Exception- Bases: - Exception- Raised on a conflict between the globals used to resolve annotations of a wrapped function and its wrapper. 
- -command_wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',), *, ignored_conflict_names=frozenset({}))[source]# +command_wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',), *, ignored_conflict_names=frozenset({}))[source]#
- Update the decorated function to look like - wrapped, and update globals for discord.py forwardref evaluation.- See - update_wrapper_globals()for more details on how the globals are updated.- Parameters:
- 
-
- wrapped ( - Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]) – The function to wrap with. 
-
- assigned ( - Sequence[- str]) – Sequence of attribute names that are directly assigned from- wrappedto- wrapper. 
-
- updated ( - Sequence[- str]) – Sequence of attribute names that are- .update``d on ``wrapperfrom the attributes on- wrapped. 
-
- ignored_conflict_names ( - Set[- str]) – A set of names to ignore if a conflict between them is found. 
+
- wrapped ( - Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]) – The function to wrap with. 
+
- assigned ( - Sequence[- str]) – Sequence of attribute names that are directly assigned from- wrappedto- wrapper. 
+
- updated ( - Sequence[- str]) – Sequence of attribute names that are- .update``d on ``wrapperfrom the attributes on- wrapped. 
+
- ignored_conflict_names ( - Set[- str]) – A set of names to ignore if a conflict between them is found.
 
- Return type: -
 +- Callable[[- Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]],- Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]]- Callable[[- Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]],- Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]]
- Returns: -
- A decorator that behaves like - functools.wraps(), +- A decorator that behaves like - functools.wraps(), with the wrapper replaced with the function- update_wrapper_globals()returned.
 
- -update_wrapper_globals(wrapper, wrapped, *, ignored_conflict_names=frozenset({}))[source]#+update_wrapper_globals(wrapper, wrapped, *, ignored_conflict_names=frozenset({}))[source]#
- Create a copy of - wrapper, the copy’s globals are updated with- wrapped's globals.- For forwardrefs in command annotations, discord.py uses the - __global__attribute of the function to resolve their values. This breaks for decorators that replace the function because they have @@ -471,9 +475,9 @@ changes won’t be reflected in the new function’s globals.- Parameters:
- 
-
- wrapper ( - Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]) – The function to wrap. 
-
- wrapped ( - Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]) – The function to wrap with. 
-
- ignored_conflict_names ( - Set[- str]) – A set of names to ignore if a conflict between them is found. 
+
- wrapper ( - Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]) – The function to wrap. 
+
- wrapped ( - Callable[[- ParamSpec(- _P)],- TypeVar(- _R)]) – The function to wrap with. 
+
- ignored_conflict_names ( - Set[- str]) – A set of names to ignore if a conflict between them is found.
 
- Raises: @@ -481,7 +485,7 @@ changes won’t be reflected in the new function’s globals.