Implement PyStubType for either::Either (with minor revise) #212
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Minor revise for #207
Summary by Copilot
This pull request introduces support for the
either
crate in thepyo3-stub-gen
project, enabling the use ofeither::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
: Addedeither
as a dependency in the workspace and included it as an optional feature inpyo3-stub-gen
. The default features now includeeither
. [1] [2] [3]pyo3-stub-gen/src/stub_type.rs
: Added a new moduleeither
gated behind theeither
feature flag.pyo3-stub-gen/src/stub_type/either.rs
: Implemented support foreither::Either<L, R>
in stub generation by definingtype_input
andtype_output
methods that mapEither
to Python'styping.Union
.Test case fixes:
pyo3-stub-gen/src/util.rs
: Updated test cases to pass string literals directly instead of references, improving readability and correctness.