Skip to content
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
14 changes: 4 additions & 10 deletions crates/vectorless-py/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use std::sync::Arc;

use pyo3::prelude::*;
use pyo3::exceptions::PyRuntimeError;
use pyo3::prelude::*;
use pyo3_async_runtimes::tokio::future_into_py;
use tokio::sync::Mutex;

Expand Down Expand Up @@ -380,9 +380,7 @@ impl PyDocument {
future_into_py(py, async move {
let num = node_id
.strip_prefix('n')
.ok_or_else(|| {
PyRuntimeError::new_err("NodeId must start with 'n'")
})?
.ok_or_else(|| PyRuntimeError::new_err("NodeId must start with 'n'"))?
.parse::<u64>()
.map_err(|_| PyRuntimeError::new_err("Invalid NodeId"))?;
let nav = nav.lock().await;
Expand All @@ -401,9 +399,7 @@ impl PyDocument {
future_into_py(py, async move {
let num = node_id
.strip_prefix('n')
.ok_or_else(|| {
PyRuntimeError::new_err("NodeId must start with 'n'")
})?
.ok_or_else(|| PyRuntimeError::new_err("NodeId must start with 'n'"))?
.parse::<u64>()
.map_err(|_| PyRuntimeError::new_err("Invalid NodeId"))?;
let nav = nav.lock().await;
Expand All @@ -422,9 +418,7 @@ impl PyDocument {
future_into_py(py, async move {
let num = node_id
.strip_prefix('n')
.ok_or_else(|| {
PyRuntimeError::new_err("NodeId must start with 'n'")
})?
.ok_or_else(|| PyRuntimeError::new_err("NodeId must start with 'n'"))?
.parse::<u64>()
.map_err(|_| PyRuntimeError::new_err("Invalid NodeId"))?;
let nav = nav.lock().await;
Expand Down
11 changes: 6 additions & 5 deletions crates/vectorless-py/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

//! Engine Python wrapper — async compile/forget/list_documents.

use pyo3::prelude::*;
use pyo3::exceptions::PyRuntimeError;
use pyo3::prelude::*;
use pyo3_async_runtimes::tokio::future_into_py;
use std::sync::Arc;
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -73,7 +73,9 @@ async fn run_load_document(engine: Arc<Engine>, doc_id: String) -> PyResult<PyDo
let navigator = vectorless_primitives::DocumentNavigator::new(d);
Ok(PyDocument::from_navigator(navigator))
}
None => Err(PyRuntimeError::new_err(format!("Document not found: {doc_id}"))),
None => Err(PyRuntimeError::new_err(format!(
"Document not found: {doc_id}"
))),
}
}

Expand Down Expand Up @@ -166,9 +168,8 @@ impl PyEngine {
builder.build().await
});

let engine = engine.map_err(|e| {
PyRuntimeError::new_err(format!("Failed to create engine: {}", e))
})?;
let engine = engine
.map_err(|e| PyRuntimeError::new_err(format!("Failed to create engine: {}", e)))?;

Ok(Self {
inner: Arc::new(engine),
Expand Down
Loading