Skip to content

Commit

Permalink
do not cache signatures: some guys uses mutable defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinolog committed Apr 30, 2019
1 parent a099e73 commit eebf447
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion logwrap/log_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ def _get_function_wrapper(
:return: wrapped coroutine or function
:rtype: typing.Callable
"""
sig: inspect.Signature = inspect.signature(self._spec or func)

# pylint: disable=missing-docstring
# noinspection PyCompatibility,PyMissingOrEmptyDocstring
@functools.wraps(func)
async def async_wrapper(*args, **kwargs): # type: (typing.Any, typing.Any) -> typing.Any
sig: inspect.Signature = inspect.signature(self._spec or func)
args_repr: str = self._get_func_args_repr(sig=sig, args=args, kwargs=kwargs)

try:
Expand All @@ -600,6 +600,7 @@ async def async_wrapper(*args, **kwargs): # type: (typing.Any, typing.Any) -> t
# noinspection PyCompatibility,PyMissingOrEmptyDocstring
@functools.wraps(func)
def wrapper(*args, **kwargs): # type: (typing.Any, typing.Any) -> typing.Any
sig: inspect.Signature = inspect.signature(self._spec or func)
args_repr: str = self._get_func_args_repr(sig=sig, args=args, kwargs=kwargs)

try:
Expand Down
3 changes: 2 additions & 1 deletion logwrap/log_wrap.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ cdef class LogWrap(class_decorator.BaseDecorator):
:return: wrapped coroutine or function
:rtype: typing.Callable
"""
sig = inspect.signature(self._spec or func)

@functools.wraps(func)
async def async_wrapper(*args, **kwargs): # type: (typing.Any, typing.Any) -> typing.Any
sig = inspect.signature(self._spec or func)
args_repr = self._get_func_args_repr(sig=sig, args=args, kwargs=kwargs)

try:
Expand All @@ -423,6 +423,7 @@ cdef class LogWrap(class_decorator.BaseDecorator):

@functools.wraps(func)
def wrapper(*args, **kwargs): # type: (typing.Any, typing.Any) -> typing.Any
sig = inspect.signature(self._spec or func)
args_repr = self._get_func_args_repr(sig=sig, args=args, kwargs=kwargs)

try:
Expand Down

0 comments on commit eebf447

Please sign in to comment.