Skip to content

Implement PyStubType for either::Either (with minor revise) #212

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

Merged
merged 5 commits into from
May 31, 2025

Conversation

termoshtt
Copy link
Member

@termoshtt termoshtt commented 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: 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] [2] [3]
  • pyo3-stub-gen/src/stub_type.rs: Added a new module either gated behind the either feature flag.
  • pyo3-stub-gen/src/stub_type/either.rs: 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: Updated test cases to pass string literals directly instead of references, improving readability and correctness.

@termoshtt termoshtt self-assigned this May 31, 2025
@termoshtt termoshtt changed the title Implement PyStubType for either::Either Implement PyStubType for either::Either (with minor revise) May 31, 2025
@termoshtt termoshtt requested a review from Copilot May 31, 2025 06:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the PyStubType trait for the either::Either type as part of the minor revisions for issue #207. Key changes include:

  • Updating test assertions in util.rs to pass string literals instead of references.
  • Adding a new implementation for PyStubType in either.rs.
  • Introducing the "either" feature and dependency in Cargo.toml files.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyo3-stub-gen/src/util.rs Updated test assertions to pass string literals directly.
pyo3-stub-gen/src/stub_type/either.rs New implementation of PyStubType for either::Either.
pyo3-stub-gen/src/stub_type.rs Added module inclusion for the new either feature.
pyo3-stub-gen/Cargo.toml Updated to include the new either dependency and feature in default list.
Cargo.toml Added the either dependency to the workspace dependencies.

@termoshtt termoshtt merged commit 0709cfb into main May 31, 2025
14 checks passed
@termoshtt termoshtt deleted the pr/YuantianDing/207 branch May 31, 2025 06:39
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