Skip to content

Commit 3ef3dd8

Browse files
authored
fix: some lint in the rust code (#250)
1 parent 61c578c commit 3ef3dd8

File tree

5 files changed

+53
-42
lines changed

5 files changed

+53
-42
lines changed

.github/workflows/python.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ jobs:
7676
- name: Static type check
7777
run: uv run --active --directory python mypy .
7878

79+
# TODO: Move this to a rust workflow once we have one.
80+
- name: Run rust lint
81+
run: pushd python/handlebarrz && cargo clippy --all-targets --all-features -- -D warnings && popd
82+
7983
- name: Check licenses
8084
run: ./scripts/check_license
8185

python/handlebarrz/Cargo.lock

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

python/handlebarrz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ name = "handlebarrz"
1515

1616
[dependencies]
1717
handlebars = "6.3.2"
18-
pyo3 = { version = "0.24.0", features = [
18+
pyo3 = { version = "0.24.2", features = [
1919
"extension-module",
2020
"generate-import-lib",
2121
] }

python/handlebarrz/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl HelperDef for PyHelperDef {
108108
Ok(json) => json,
109109
Err(e) => {
110110
let desc = format!("Failed to serialize params: {}", e);
111-
return Err(RenderError::from(RenderErrorReason::Other(desc.into())));
111+
return Err(RenderError::from(RenderErrorReason::Other(desc)));
112112
}
113113
};
114114

@@ -122,7 +122,7 @@ impl HelperDef for PyHelperDef {
122122
Ok(json) => json,
123123
Err(e) => {
124124
let desc = format!("Failed to serialize hash: {}", e);
125-
return Err(RenderError::from(RenderErrorReason::Other(desc.into())));
125+
return Err(RenderError::from(RenderErrorReason::Other(desc)));
126126
}
127127
};
128128

@@ -131,7 +131,7 @@ impl HelperDef for PyHelperDef {
131131
Ok(json) => json,
132132
Err(e) => {
133133
let desc = format!("Failed to serialize context: {}", e);
134-
return Err(RenderError::from(RenderErrorReason::Other(desc.into())));
134+
return Err(RenderError::from(RenderErrorReason::Other(desc)));
135135
}
136136
};
137137

@@ -144,15 +144,15 @@ impl HelperDef for PyHelperDef {
144144
Ok(s) => s,
145145
Err(e) => {
146146
let desc = format!("Failed to extract result: {}", e);
147-
return Err(RenderError::from(RenderErrorReason::Other(desc.into())));
147+
return Err(RenderError::from(RenderErrorReason::Other(desc)));
148148
}
149149
};
150150
out.write(&result_str)?;
151151
Ok(())
152152
}
153153
Err(e) => {
154154
let desc = format!("Helper execution failed: {}", e);
155-
Err(RenderError::from(RenderErrorReason::Other(desc.into())))
155+
Err(RenderError::from(RenderErrorReason::Other(desc)))
156156
}
157157
}
158158
})
@@ -613,8 +613,9 @@ impl HelperDef for UnlessEqualsHelper {
613613
///
614614
/// ## Hash Arguments
615615
///
616-
/// * `indent`: Optional. If provided, the JSON output will be pretty-printed with the specified indent level (integer).
617-
/// If not provided, the JSON output will be compact (no whitespace).
616+
/// * `indent`: Optional. If provided, the JSON output will be pretty-printed
617+
/// with the specified indent level (integer). If not provided, the JSON
618+
/// output will be compact (no whitespace).
618619
///
619620
/// This helper is useful for embedding JSON data directly into templates,
620621
/// for example, to pass configuration or data to client-side JavaScript code.

scripts/lint

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ TOP_DIR=$(git rev-parse --show-toplevel)
2222
GO_DIR="${TOP_DIR}/go"
2323
PY_DIR="${TOP_DIR}/python"
2424
JS_DIR="${TOP_DIR}/js"
25+
HANDLEBARRZ_DIR="${TOP_DIR}/python/handlebarrz"
2526

2627
pushd "${GO_DIR}" &>/dev/null
2728
golangci-lint run ./...
@@ -33,3 +34,8 @@ popd &>/dev/null
3334

3435
uv run --directory "${PY_DIR}" ruff check --select I --fix --preview --unsafe-fixes .
3536
uv run --directory "${PY_DIR}" mypy .
37+
38+
pushd "${HANDLEBARRZ_DIR}" &>/dev/null
39+
cargo fmt --all
40+
cargo clippy --all-targets --all-features -- -D warnings
41+
popd &>/dev/null

0 commit comments

Comments
 (0)