Skip to content

Implement PyStubType for either::Either #207

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

Closed
wants to merge 1 commit into from

Conversation

YuantianDing
Copy link
Contributor

termoshtt added a commit that referenced this pull request May 31, 2025
Minor revise for #207

Summary by Copilot
-------------------

This pull request introduces support for the `either` crate in the
`pyo3-stub-gen` project, enabling the use of `either::Either` types in
Python stub generation. It also includes minor fixes to existing test
cases for improved clarity and correctness.

### Integration of the `either` crate:

*
[`Cargo.toml`](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R22):
Added `either` as a dependency in the workspace and included it as an
optional feature in `pyo3-stub-gen`. The default features now include
`either`.
[[1]](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R22)
[[2]](diffhunk://#diff-d2fe0506288d6d1bb990e8185c26e0cdf07ee85787eb78c2bb3d60b70bf88eb0R21)
[[3]](diffhunk://#diff-d2fe0506288d6d1bb990e8185c26e0cdf07ee85787eb78c2bb3d60b70bf88eb0L33-R36)
*
[`pyo3-stub-gen/src/stub_type.rs`](diffhunk://#diff-bec31605b52ecbf7a424c6bcc8dfcf155d211d25316e27ba0945b49284470ae8R8-R10):
Added a new module `either` gated behind the `either` feature flag.
*
[`pyo3-stub-gen/src/stub_type/either.rs`](diffhunk://#diff-5d12c671f041e17061b398055bb9cb24b0360e7af721e1985f863a49b0e446dbR1-R44):
Implemented support for `either::Either<L, R>` in stub generation by
defining `type_input` and `type_output` methods that map `Either` to
Python's `typing.Union`.

### Test case fixes:

*
[`pyo3-stub-gen/src/util.rs`](diffhunk://#diff-1c01740ca518ff53dff74391ba7e3427fba3221cc3c19de143bcf2568f253e87L114-R116):
Updated test cases to pass string literals directly instead of
references, improving readability and correctness.

---------

Co-authored-by: YuantianDing <[email protected]>
@termoshtt
Copy link
Member

Merged via #212

@termoshtt termoshtt closed this May 31, 2025
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