Skip to content

[stubgen] Fix a few bugs with stubgen of c modules #11096

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 3 commits into from
Sep 14, 2021

Conversation

chadrik
Copy link
Contributor

@chadrik chadrik commented Sep 12, 2021

Description

This fixes three issues encountered while trying to generate stubs from a c module:

  1. Fix bug when inferring signatures with no args. In this case, the signature has one arg which has an empty name.
  2. Add a self arg to the inferred signature for a method, when it is omitted from docstring signature. stubgen has a feature that will read the signature from the function's docstrings, but it would happily accept methods that did not specify a self-arg.
  3. Use 'cls' as self arg for classmethods without signature info. Simple fix to produce better stubs for classmethods defined in c modules.

Test Plan

Each of these changes has a test which clearly shows the change.

I've left each of these changes as their own commit, and each could be a separate MR, but they are so simple I've left them in one MR. Let me know if you want me to break this up.

@JelleZijlstra JelleZijlstra merged commit e654572 into python:master Sep 14, 2021
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.

2 participants