Skip to content

Commit 60f72b1

Browse files
committed
chore(fmt): rustfmt cleanup for action_emitter + link_chain + odoo_ontology
Pure rustfmt output (cargo fmt -p lance-graph). Line-wrapping preferences (collapse 4-line .get/.unwrap_or chains, expand single-line function signatures past 100 cols). No semantic changes. Fixes the `format` CI check on PR #432.
1 parent 1bb7807 commit 60f72b1

3 files changed

Lines changed: 39 additions & 29 deletions

File tree

crates/lance-graph/src/graph/spo/action_emitter.rs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,7 @@ fn compose_spec(fn_id: &str, idx: &TripleIndex) -> ActionSpec {
243243

244244
// `effects` must materialize as a Vec at the end, but we also iterate it
245245
// to drive `inputs` below — borrow the source set, then collect once.
246-
let effects_set: &BTreeSet<String> = idx
247-
.emits_by_fn
248-
.get(fn_id)
249-
.unwrap_or(&EMPTY_SET);
246+
let effects_set: &BTreeSet<String> = idx.emits_by_fn.get(fn_id).unwrap_or(&EMPTY_SET);
250247

251248
let mut inputs: BTreeSet<String> = BTreeSet::new();
252249
for effect in effects_set {
@@ -270,8 +267,7 @@ fn compose_spec(fn_id: &str, idx: &TripleIndex) -> ActionSpec {
270267
/// each element once (vs `.cloned().unwrap_or_default()` which clones the
271268
/// entire tree before re-collecting).
272269
fn collect_sorted(set: Option<&BTreeSet<String>>) -> Vec<String> {
273-
set.map(|s| s.iter().cloned().collect())
274-
.unwrap_or_default()
270+
set.map(|s| s.iter().cloned().collect()).unwrap_or_default()
275271
}
276272

277273
/// Singleton empty set so `compose_spec` can borrow a reference for the
@@ -398,12 +394,15 @@ mod tests {
398394
);
399395
assert_eq!(cm.raises, vec!["exc:UserError".to_string()]);
400396
assert_eq!(cm.reads, vec!["odoo:account_move.currency_id".to_string()]);
401-
assert_eq!(
402-
cm.traverses,
403-
vec!["odoo:account_move.line_ids".to_string()]
397+
assert_eq!(cm.traverses, vec!["odoo:account_move.line_ids".to_string()]);
398+
assert!(
399+
!cm.is_pure_compute(),
400+
"raises non-empty disqualifies pure compute"
401+
);
402+
assert!(
403+
!cm.is_pure_guard(),
404+
"effects non-empty disqualifies pure guard"
404405
);
405-
assert!(!cm.is_pure_compute(), "raises non-empty disqualifies pure compute");
406-
assert!(!cm.is_pure_guard(), "effects non-empty disqualifies pure guard");
407406
assert!(!cm.is_trivial());
408407
}
409408

@@ -435,7 +434,11 @@ mod tests {
435434
fn emit_non_trivial_drops_empties() {
436435
let mut t = fixture();
437436
// Add a function with no edges at all.
438-
t.push(triple("odoo:account_move._stub", "rdf:type", "ogit:Function"));
437+
t.push(triple(
438+
"odoo:account_move._stub",
439+
"rdf:type",
440+
"ogit:Function",
441+
));
439442

440443
let all = emit_actions(&t);
441444
let non_trivial = emit_non_trivial_actions(&t);
@@ -445,7 +448,9 @@ mod tests {
445448
"stub should appear in full output"
446449
);
447450
assert!(
448-
!non_trivial.iter().any(|s| s.id == "odoo:account_move._stub"),
451+
!non_trivial
452+
.iter()
453+
.any(|s| s.id == "odoo:account_move._stub"),
449454
"stub should be filtered from non_trivial output"
450455
);
451456
}
@@ -493,7 +498,10 @@ mod tests {
493498

494499
#[test]
495500
fn family_of_handles_dotted_iri() {
496-
assert_eq!(family_of("odoo:account_move._compute_amount"), "account_move");
501+
assert_eq!(
502+
family_of("odoo:account_move._compute_amount"),
503+
"account_move"
504+
);
497505
assert_eq!(family_of("odoo:res_partner.name"), "res_partner");
498506
assert_eq!(family_of("odoo:standalone"), "standalone");
499507
// No `odoo:` prefix — IRI returned as-is up to the first dot.
@@ -522,7 +530,10 @@ mod tests {
522530
triple("odoo:m.unrelated", "depends_on", "odoo:m.something"),
523531
];
524532
let specs = emit_actions(&triples);
525-
let g = specs.iter().find(|s| s.id == "odoo:m._guard").expect("guard");
533+
let g = specs
534+
.iter()
535+
.find(|s| s.id == "odoo:m._guard")
536+
.expect("guard");
526537
assert!(g.effects.is_empty(), "no emitted_by ⇒ no effects");
527538
assert!(
528539
g.inputs.is_empty(),

crates/lance-graph/src/graph/spo/link_chain.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ pub fn split_chain(path: &str) -> Option<LinkChain> {
169169
/// hops, leaf)` and deduplicated. Re-running on the same input produces
170170
/// byte-identical output.
171171
#[must_use]
172-
pub fn split_all_depends_on(
173-
triples: &[OntologyTriple],
174-
) -> BTreeMap<String, Vec<LinkChain>> {
172+
pub fn split_all_depends_on(triples: &[OntologyTriple]) -> BTreeMap<String, Vec<LinkChain>> {
175173
let mut by_source: BTreeMap<String, Vec<LinkChain>> = BTreeMap::new();
176174
for t in triples {
177175
if t.p != "depends_on" {

crates/lance-graph/src/graph/spo/odoo_ontology.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,18 @@ mod tests {
120120
use std::collections::BTreeMap;
121121
let mut hist: BTreeMap<&str, usize> = BTreeMap::new();
122122
for t in parse_triples(ONTOLOGY) {
123-
*hist.entry(match t.p.as_str() {
124-
"rdf:type" => "rdf:type",
125-
"depends_on" => "depends_on",
126-
"has_function" => "has_function",
127-
"emitted_by" => "emitted_by",
128-
"reads_field" => "reads_field",
129-
"raises" => "raises",
130-
"traverses_relation" => "traverses_relation",
131-
_ => "other",
132-
})
133-
.or_default() += 1;
123+
*hist
124+
.entry(match t.p.as_str() {
125+
"rdf:type" => "rdf:type",
126+
"depends_on" => "depends_on",
127+
"has_function" => "has_function",
128+
"emitted_by" => "emitted_by",
129+
"reads_field" => "reads_field",
130+
"raises" => "raises",
131+
"traverses_relation" => "traverses_relation",
132+
_ => "other",
133+
})
134+
.or_default() += 1;
134135
}
135136
// Provenance-authoritative edge classes are present and non-trivial.
136137
assert_eq!(hist.get("depends_on"), Some(&6309));

0 commit comments

Comments
 (0)