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

Python: generate type stubs for all user functions #1506

Merged
merged 5 commits into from
Jun 16, 2023
Merged

Python: generate type stubs for all user functions #1506

merged 5 commits into from
Jun 16, 2023

Conversation

badboy
Copy link
Member

@badboy badboy commented Apr 3, 2023

After getting asked about it the other day on reddit I figured I give it a go.
Turns out generating the right types in Python is possible and pleases mypy when used in Glean as well (for the most part).

There's some not-yet fixed cases, I want to add some testing and ensure this reliably works, so marking this as WIP for the moment.

@badboy badboy force-pushed the mypy-types branch 3 times, most recently from feb0ff4 to 14f274a Compare April 24, 2023 16:25
@badboy badboy marked this pull request as ready for review April 25, 2023 09:07
@badboy badboy requested a review from a team as a code owner April 25, 2023 09:07
@badboy badboy requested review from bendk and removed request for a team April 25, 2023 09:07
Copy link
Member

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

LGTM but it might make sense to update that comment?

uniffi_bindgen/src/interface/types/mod.rs Outdated Show resolved Hide resolved
@heinrich5991
Copy link
Contributor

What's the status of this? The changes seem approved. Does it only need a rebase? (Is help with the rebase wanted?)

@badboy
Copy link
Member Author

badboy commented Jun 15, 2023

What's the status of this? The changes seem approved. Does it only need a rebase? (Is help with the rebase wanted?)

Ah yes, this once again needs a rebase. It fell through a bit due to other work, but I can take this up today.

1. Methods of a callback expect `self` as the first argument (instance methods)
2. `contextlib.contextmanager`-methods require _some_ args (according to
   `mypy`), so we use a catchall (where nothing is fine too)
@badboy badboy force-pushed the mypy-types branch 2 times, most recently from 04ee66a to b4aa69c Compare June 15, 2023 14:41
@badboy badboy added this to the v0.24.0 milestone Jun 15, 2023
@badboy badboy merged commit 62a9c74 into main Jun 16, 2023
@badboy badboy deleted the mypy-types branch June 16, 2023 12:52
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.

3 participants