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

Some Improvments for getter #137

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add indexmap feature
  • Loading branch information
zao111222333 committed Jan 16, 2025
commit 25cb9f243be5cc702a174f9625c46193201cdf1c
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ anyhow = "1.0.95"
chrono = "0.4.39"
env_logger = "0.11.6"
insta = "1.42.0"
indexmap = "2.7.0"
inventory = "0.3.16"
itertools = "0.13.0"
log = "0.4.22"
Expand Down
1 change: 1 addition & 0 deletions pyo3-stub-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ readme.workspace = true
[dependencies]
anyhow.workspace = true
chrono.workspace = true
indexmap = { workspace = true, optional = true }
inventory.workspace = true
itertools.workspace = true
log.workspace = true
Expand Down
14 changes: 14 additions & 0 deletions pyo3-stub-gen/src/stub_type/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ impl<T: PyStubType> PyStubType for BTreeSet<T> {
}
}

#[cfg(feature = "indexmap")]
impl<T: PyStubType, State> PyStubType for indexmap::IndexSet<T, State> {
fn type_output() -> TypeInfo {
HashSet::<T, State>::type_output()
}
}

macro_rules! impl_map_inner {
() => {
fn type_input() -> TypeInfo {
Expand Down Expand Up @@ -147,6 +154,13 @@ impl<Key: PyStubType, Value: PyStubType, State> PyStubType for HashMap<Key, Valu
impl_map_inner!();
}

#[cfg(feature = "indexmap")]
impl<Key: PyStubType, Value: PyStubType, State> PyStubType
for indexmap::IndexMap<Key, Value, State>
{
impl_map_inner!();
}

macro_rules! impl_tuple {
($($T:ident),*) => {
impl<$($T: PyStubType),*> PyStubType for ($($T),*) {
Expand Down