Skip to content
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

Update sageinspect.getargspec to handle keyword only arguments #39774

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Biffo89
Copy link

@Biffo89 Biffo89 commented Mar 23, 2025

Fixes #39627

Keyword-only arguments were added in Python 3 and are not being handled properly by sageinspect, causing documentation to have incorrect signatures, including incorrect default arguments.

This PR replaces a usage of the deprecated inspect.getargs and inspect.FullArgSpec with inspect.getfullargspec.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link
Contributor

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your PR.

There are a few more calls to inspect.getargs further down in the same method. Could you please replace them as well? (Looking at the code, it appears to me that func_obj is always obj, so the first call with inspect.getargs(func_obj.__code__) is actually a duplicate and can be removed.)

Finally, if you have time, could you please try if inspect.signature works better/the same than getfullargspec. The latter is scheduled for deprecation, see python/cpython#108901 (although this seems to lie dormant for some time now).

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

Successfully merging this pull request may close these issues.

Documentation shows incorrect default values for keyword-only arguments
2 participants