Skip to content

Stub generation & introspection: emit async keyword for async functions#5731

Merged
Tpt merged 4 commits intoPyO3:mainfrom
stijndcl:feat/introspect-async-fn
Jan 12, 2026
Merged

Stub generation & introspection: emit async keyword for async functions#5731
Tpt merged 4 commits intoPyO3:mainfrom
stijndcl:feat/introspect-async-fn

Conversation

@stijndcl
Copy link
Copy Markdown
Contributor

Currently, async functions do not emit the async keyword when introspected.

#[pyfunction]
async fn foo() {}

results in

def foo() -> None: ...

This MR checks the asyncness of a function, and emits "async " if required. For properties (getters and setters) this is unnecessary because these are never async, so in this case a hardcoded false is used instead.

@stijndcl stijndcl changed the title Introspection: emit async keyword for async functions Stub generation & introspection: emit async keyword for async functions Jan 12, 2026
Copy link
Copy Markdown
Contributor

@Tpt Tpt left a comment

Choose a reason for hiding this comment

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

Thank you! Just one nit

Comment thread pytests/src/pyfunctions.rs Outdated
@Tpt Tpt added this pull request to the merge queue Jan 12, 2026
Merged via the queue into PyO3:main with commit 185e6b3 Jan 12, 2026
43 checks passed
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