Skip to content

Commit 216dee2

Browse files
committed
Reimplement import graph
1 parent 382d7a2 commit 216dee2

16 files changed

Lines changed: 1517 additions & 3400 deletions

rust/Cargo.lock

Lines changed: 129 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@ name = "_rustgrimp"
88
crate-type = ["cdylib", "rlib"]
99

1010
[dependencies]
11-
log = "0.4.19"
12-
pyo3-log = "0.12.1"
13-
serde_json = "1.0.103"
1411
rayon = "1.10"
15-
petgraph = "0.6.5"
1612
bimap = "0.6.3"
13+
slotmap = "1.0.7"
14+
getset = "0.1.3"
15+
derive-new = "0.7.0"
16+
lazy_static = "1.5.0"
17+
string-interner = "0.18.0"
18+
thiserror = "2.0.11"
19+
itertools = "0.14.0"
20+
tap = "1.0.1"
1721
rustc-hash = "2.1.0"
22+
indexmap = "2.7.1"
1823

1924
[dependencies.pyo3]
2025
version = "0.23.4"
2126

2227
[features]
2328
extension-module = ["pyo3/extension-module"]
2429
default = ["extension-module"]
30+
31+
[dev-dependencies]
32+
serde_json = "1.0.137"

rust/src/errors.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::exceptions::{ModuleNotPresent, NoSuchContainer};
2+
use pyo3::exceptions::PyValueError;
3+
use pyo3::PyErr;
4+
use thiserror::Error;
5+
6+
#[derive(Debug, Error)]
7+
pub enum GrimpError {
8+
#[error("Module {0} is not present in the graph.")]
9+
ModuleNotPresent(String),
10+
11+
#[error("Container {0} does not exist.")]
12+
NoSuchContainer(String),
13+
14+
#[error("Modules have shared descendants.")]
15+
SharedDescendants,
16+
}
17+
18+
pub type GrimpResult<T> = Result<T, GrimpError>;
19+
20+
impl From<GrimpError> for PyErr {
21+
fn from(value: GrimpError) -> Self {
22+
// A default mapping from `GrimpError`s to python exceptions.
23+
match value {
24+
GrimpError::ModuleNotPresent(_) => ModuleNotPresent::new_err(value.to_string()),
25+
GrimpError::NoSuchContainer(_) => NoSuchContainer::new_err(value.to_string()),
26+
GrimpError::SharedDescendants => PyValueError::new_err(value.to_string()),
27+
}
28+
}
29+
}

rust/src/exceptions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use pyo3::create_exception;
2+
3+
create_exception!(_rustgrimp, ModuleNotPresent, pyo3::exceptions::PyException);
4+
create_exception!(_rustgrimp, NoSuchContainer, pyo3::exceptions::PyException);

0 commit comments

Comments
 (0)