From 9b045ff5d6588a24a0bab52c83f032e2ba433e17 Mon Sep 17 00:00:00 2001 From: uyoung-jeong Date: Thu, 6 Jun 2024 12:35:38 +0900 Subject: [PATCH] fix getargspec deprecation in python 3.11 --- chumpy/ch.py | 10 +++++++--- chumpy/version.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chumpy/ch.py b/chumpy/ch.py index e903df9..a223bdf 100644 --- a/chumpy/ch.py +++ b/chumpy/ch.py @@ -1189,7 +1189,11 @@ def compute_dr_wrt(self, wrt): # return func(self, *args, **kwargs) # return property(with_caching) # return _depends_on - +def getargspec(func): + if hasattr(inspect, 'getargspec'): # backward compatibility + return inspect.getargspec(func) + else: # python 3.11 compatibility + return inspect.getfullargspec(func) def depends_on(*dependencies): deps = set() @@ -1200,7 +1204,7 @@ def depends_on(*dependencies): [deps.add(d) for d in dep] def _depends_on(func): - want_out = 'out' in inspect.getargspec(func).args + want_out = 'out' in getargspec(func).args @wraps(func) def with_caching(self, *args, **kwargs): @@ -1243,7 +1247,7 @@ def on_changed(self, which): self.args[argname].x = getattr(self, argname) def __init__(self, lmb, initial_args=None): - args = {argname: ChHandle(x=Ch(idx)) for idx, argname in enumerate(inspect.getargspec(lmb)[0])} + args = {argname: ChHandle(x=Ch(idx)) for idx, argname in enumerate(getargspec(lmb)[0])} if initial_args is not None: for initial_arg in initial_args: if initial_arg in args: diff --git a/chumpy/version.py b/chumpy/version.py index 1fa3d21..aa4403f 100644 --- a/chumpy/version.py +++ b/chumpy/version.py @@ -1,3 +1,3 @@ -version = '0.71' +version = '0.72' short_version = version full_version = version