Skip to content

Commit

Permalink
Fix deprecation warning of formatargspec (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPansino authored Jun 22, 2021
1 parent de6929d commit a58dcfc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions newrelic/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ def _argspec_py3(func):
else:
_argspec = _argspec_py2

try:
from inspect import signature
from collections import OrderedDict
def doc_signature(func):
sig = signature(func)
sig._parameters = OrderedDict(list(sig._parameters.items())[1:])
return str(sig)
except ImportError:
from inspect import formatargspec
def doc_signature(func):
args, varargs, keywords, defaults = _argspec(func)
return formatargspec(args[1:], varargs, keywords, defaults)

from newrelic.core.agent import agent_instance
from newrelic.core.config import global_settings, flatten_settings
from newrelic.api.transaction import Transaction
Expand Down Expand Up @@ -81,8 +94,8 @@ def wrapper(self, line):
return wrapped(self, *args, **kwargs)

if wrapper.__name__.startswith('do_'):
prototype = wrapper.__name__[3:] + ' ' + inspect.formatargspec(
args[1:], varargs, keywords, defaults)
prototype = wrapper.__name__[3:] + ' ' + doc_signature(wrapped)

if hasattr(wrapper, '__doc__') and wrapper.__doc__ is not None:
wrapper.__doc__ = '\n'.join((prototype,
wrapper.__doc__.lstrip('\n')))
Expand Down

0 comments on commit a58dcfc

Please sign in to comment.