Migrate to inspect.getfullargspec() (#844)

getargspec() was deprecated in 3.0 and removed in 3.11.
This commit is contained in:
Stefano Rivera 2022-12-25 22:42:06 -08:00 committed by GitHub
parent 29f78b3207
commit 19600d8e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,13 +122,14 @@ class Module(SettingsBase):
tmp_cb = cb
try:
args_spec = inspect.getargspec(tmp_cb)
args_spec = inspect.getfullargspec(tmp_cb)
except Exception:
args_spec = inspect.ArgSpec([], None, None, None)
args_spec = inspect.FullArgSpec(
[], None, None, None, None, None, {})
# Remove all variables present in kwargs that are not used in the
# callback, except if there is a keyword argument.
if not args_spec.keywords:
if not args_spec.varkw:
kwargs = {k: v for k, v in kwargs.items()
if k in args_spec.args}
cb(*args, **kwargs)