-
Notifications
You must be signed in to change notification settings - Fork 54
Use getfullargspec over deprecated getargspec #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
sass.py
Outdated
if argspec.varargs or argspec.keywords or argspec.defaults: | ||
if PY3: | ||
argspec = inspect.getfullargspec(lambda_) | ||
varargs, varkw, defaults = (argspec.varargs, argspec.varkw, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in py35+ you'll also want to include kwonlyargs
Since this creates a disparate branch you'll probably want to include # pragma: no cover
comments on each branch
Maybe something like this?
argspec = getargspec(lambda_)
if PY2: # pragma: no cover
argspec = inspect.getargspec(lambda_)
unsuported = (...)
unsupported += (getattr(argspec, 'kwonlyargs', None),)
else: # pragma: no cover
argspec = inspect.getfullargspec(lambda_)
unsupported_argspec_attrs = (argspec.varags, argspec.keywords, argspect.defaults)
if unsupported_argspec_attrs: ...
Note that I picked a subtly different form that uses if PY2: else:
-- this makes the python3 branch continue to work in python4 (if it were ever to come out)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kwonlyargs
is not supported on getargspec
, it's something that was introduced with getfullargspec
. I'm not entirely clear what this function is used for, I just went for feature-parity. What would kwonlyargs
add over varkw
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh oops, I was in a hurry, that should only be in the python3 case (A newly added feature)
def kwonly_func(x, *, y=None):
"""y may only be passed as a kwarg"""
Thanks! |
This fixes #188