Skip to content

Add typestub generator#41377

Open
tobiasdiez wants to merge 2 commits intosagemath:developfrom
tobiasdiez:typing_gen
Open

Add typestub generator#41377
tobiasdiez wants to merge 2 commits intosagemath:developfrom
tobiasdiez:typing_gen

Conversation

@tobiasdiez
Copy link
Copy Markdown
Contributor

@tobiasdiez tobiasdiez commented Jan 3, 2026

For automatically generating/checking type stubs for Cython modules. Based on/inspired by https://github.com/Vizonex/CyStub/ (but extended to handle default values, check mode etc)

Pretty basic at the moment, main functionality is to check that the existing stubs contain exactly the methods that we expect them to have.

📝 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

@tobiasdiez
Copy link
Copy Markdown
Contributor Author

tobiasdiez commented Jan 3, 2026

TODO:

  • Fix all issues reported by the check, and then add it to CI.
  • Add unit tests
  • Improve extraction of typing info from cython annotations
  • Consider upstreaming the script to the Cython repo

@vincentmacri FYI

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 3, 2026

Documentation preview for this PR (built with commit b030c05; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@tobiasdiez tobiasdiez marked this pull request as ready for review February 14, 2026 11:47
Copy link
Copy Markdown
Member

@vincentmacri vincentmacri left a comment

Choose a reason for hiding this comment

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

This needs more documentation/comments before I can review this as I'm not familiar with the Cython libraries in use here (and presumably most other Sage contributors aren't familiar with it either).

Please add:

  • A module docstring giving a high-level overview of that this code does and how it works (include links to the documentation of the relevant Cython libraries being used)
  • Function docstrings (I don't think we need doctests, just descriptions of each function)

Do you intend to run this script in this PR and add the autogenerated typestubs as well? Any plans to upstream this to Cython?

@@ -0,0 +1,625 @@
#!/usr/bin/env python3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Your PR description says this file was taken/adapted from somewhere else? Then it needs to include the relevant copyright info.

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.

2 participants