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

build(deps): Remove unused dependencies #79

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ logging = ["dep:pyo3-log", "dep:log"]
[dependencies]
tokio = { version = "1.0", features = ["sync"] }
pyo3 = { version = "0.23.5", features = [
"anyhow",
"indexmap",
"multiple-pymethods",
"abi3-py37",
Expand All @@ -35,7 +34,6 @@ pyo3-async-runtimes = { version = "0.23.0", features = ["tokio-runtime"] }
pyo3-log = { version = "0.12.1", optional = true }
pyo3-stub-gen = "0.7.0"
log = { version = "0.4", optional = true }
anyhow = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
mime = "0.3.17"
Expand Down
54 changes: 2 additions & 52 deletions src/types/json.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use indexmap::IndexMap;
use pyo3::{prelude::*, types::PyBool};
use pyo3::prelude::*;
use pyo3_stub_gen::{PyStubType, TypeInfo};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, FromPyObject, Serialize, Deserialize)]
#[derive(Debug, Clone, FromPyObject, IntoPyObject, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Json {
Object(IndexMap<String, Json>),
Expand All @@ -20,53 +20,3 @@ impl PyStubType for Json {
TypeInfo::any()
}
}

impl<'py> IntoPyObject<'py> for Json {
type Target = PyAny;
type Output = Bound<'py, Self::Target>;
type Error = anyhow::Error;

fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
match self {
Self::Null(_) => Option::<isize>::None.into_pyobject(py).map_err(Into::into),
Self::Boolean(inner) => inner
.into_pyobject(py)
.map(|x| <pyo3::Bound<'_, PyBool> as Clone>::clone(&x).into_any())
.map_err(Into::into),

Self::String(inner) => inner
.into_pyobject(py)
.map(|x| x.into_any())
.map_err(Into::into),

Self::Float(inner) => inner
.into_pyobject(py)
.map(|x| x.into_any())
.map_err(Into::into),

Self::Number(inner) => inner
.into_pyobject(py)
.map(|x| x.into_any())
.map_err(Into::into),

Self::Array(inner) => {
let mut new_holder = Vec::with_capacity(inner.len());
for item in inner {
new_holder.push(item.into_pyobject(py)?);
}
new_holder.into_pyobject(py).map_err(Into::into)
}

Self::Object(inner) => {
let mut new_holder = IndexMap::with_capacity(inner.len());
for (key, elem) in inner {
new_holder.insert(key, elem.into_pyobject(py).map(|x| x.into_any())?);
}
new_holder
.into_pyobject(py)
.map(|x| x.into_any())
.map_err(Into::into)
}
}
}
}
Loading