Skip to content

Commit

Permalink
Merge pull request #293 from pyGSTio/bugfix-inspect-deprecations
Browse files Browse the repository at this point in the history
Replace deprecated function calls to inspect module
  • Loading branch information
sserita committed Jan 19, 2023
2 parents 2838034 + 035f16f commit 333dc02
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pygsti/report/workspace.py
Expand Up @@ -268,17 +268,16 @@ def __setstate__(self, state_dict):
def _makefactory(self, cls, autodisplay): # , printer=_objs.VerbosityPrinter(1)):
# XXX this indirection is so wild -- can we please rewrite directly?
#Manipulate argument list of cls.__init__
argspec = _inspect.getargspec(cls.__init__)
argnames = argspec[0]
argspec = _inspect.getfullargspec(cls.__init__)
argsig = _inspect.signature(cls.__init__)
argnames = argspec.args
assert(argnames[0] == 'self' and argnames[1] == 'ws'), \
"__init__ must begin with (self, ws, ...)"

factoryfn_argnames = argnames[2:] # strip off self & ws args
newargspec = (factoryfn_argnames,) + argspec[1:]


newargsig = argsig.replace(parameters= list(argsig.parameters.values())[2:])

#Define a new factory function with appropriate signature
signature = _inspect.formatargspec(
formatvalue=lambda val: "", *newargspec)
signature = str(newargsig)
signature = signature[1:-1] # strip off parenthesis from ends of "(signature)"

if autodisplay:
Expand Down

0 comments on commit 333dc02

Please sign in to comment.