8000 MNT: inspect.getfullargspec will be deprecated in py3.8 by tacaswell · Pull Request #14138 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MNT: inspect.getfullargspec will be deprecated in py3.8 #14138

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,8 @@ def _get_setters_and_targets(self):
func = getattr(self.o, name)
if not callable(func):
continue
nargs = len(inspect.getfullargspec(func).args)
nargs = len([p for p in inspect.signature(func).parameters.values()
if p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD])
if nargs < 2 or self.is_alias(func):
continue
source_class = self.o.__module__ + "." + self.o.__name__
Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/patches.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -1863,12 +1863,11 @@ def _pprint_styles(_styles):
_table = [["Class", "Name", "Attrs"]]

for name, cls in sorted(_styles.items()):
spec = inspect.getfullargspec(cls.__init__)
if spec.defaults:
argstr = ", ".join(map(
"{}={}".format, spec.args[-len(spec.defaults):], spec.defaults
))
else:
sig = inspect.signature(cls.__init__)
argstr = ", ".join(
f"{p.name}={p.default}"
Copy link
Contributor
@anntzer anntzer May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually that's just str(p) (which will print out as name=default in presence of a default, isn't the stdlib wonderful? :p)


and the whole thing can be simplified down to

        argstr = (str(inspect.signature(cls))[1:-1]  # Strip parentheses.
                  or "None")

because style classes don't take other arguments, and inspect.signature(cls) helpfully drops self from the signature of __init__...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if something seems like it is too hard, it probably is"

for p in sig.parameters.values() if p.default is not p.empty)
if not argstr:
argstr = 'None'
# adding ``quotes`` since - and | have special meaning in reST
_table.append([cls.__name__, "``%s``" % name, argstr])
Expand Down
0