Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Feb 28, 2017
Merged

Use getfullargspec over deprecated getargspec #189

merged 1 commit into from
Feb 28, 2017

Conversation

thomwiggers
Copy link
Contributor

This fixes #188

@coveralls
Copy link

coveralls commented Feb 27, 2017

Coverage Status

Coverage decreased (-0.2%) to 94.315% when pulling 13f6a07 on thomwiggers:argspec_deprecated into e5b9237 on dahlia:master.

@coveralls
Copy link

coveralls commented Feb 27, 2017

Coverage Status

Coverage increased (+0.02%) to 94.506% when pulling 2909321 on thomwiggers:argspec_deprecated into e5b9237 on dahlia:master.

Copy link
Member

@asottile asottile left a 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,
Copy link
Member

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)

Copy link
Contributor Author

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?

Copy link
Member

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"""

@coveralls
Copy link

coveralls commented Feb 28, 2017

Coverage Status

Coverage decreased (-0.005%) to 94.483% when pulling 7355df6 on thomwiggers:argspec_deprecated into e5b9237 on dahlia:master.

@asottile asottile merged commit 296ca8d into sass:master Feb 28, 2017
@asottile
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inspect.getargspec is deprecated
3 participants