Skip to content

Commit

Permalink
fillerbase: Drop usage of inspect.getargspec() (#14)
Browse files Browse the repository at this point in the history
inspect.getargspec() was deprecated in Python 3.3, and removed in
Python 3.11.  Change to using inspect.signature to see if the method
accepts keyword arguments.

Fixes: #13
  • Loading branch information
jackrosenthal authored Feb 16, 2024
1 parent 03a2821 commit 67ceff7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sprox/fillerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,13 @@ def get_value(self, values=None, **kw):
for field in self.__fields__:
field_method = getattr(self, field, None)
if inspect.ismethod(field_method):
argspec = inspect.getargspec(field_method)
if argspec and (len(argspec[0])-2>=len(kw) or argspec[2]):
value = getattr(self, field)(obj, **kw)
signature = inspect.signature(field_method)
try:
signature.bind(obj, **kw)
except TypeError:
value = field_method(obj)
else:
value = getattr(self, field)(obj)
value = field_method(obj, **kw)
else:
value = getattr(obj, field)
if 'password' in field.lower():
Expand Down

0 comments on commit 67ceff7

Please sign in to comment.