Skip to content

Fix stub generation for imported methods #1055

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

inducer
Copy link

@inducer inducer commented May 22, 2025

Currently, stub generation mishandles the case where a method is actually a function imported from a different module. (It simply imports the name as the name of the method and calls it a day. A name never gets added to the class namespace.)

This can arise, for example, if one adds methods to nanobind-generated classes via monkeypatching.

Full disclosure: this is a bit of a drive-by PR. I did not investigate if/how type stubs are tested. If you'd like me to add testing or make other revisions, I would be happy to.

@inducer inducer marked this pull request as draft May 22, 2025 19:18
@inducer inducer mentioned this pull request May 22, 2025
12 tasks
@wjakob
Copy link
Owner

wjakob commented Jun 1, 2025

Could you please add a test that covers this new feature? You will also need to update the stub reference files.

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