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

Update clippy to run for all targets and with python-bindings feature #61

Merged
merged 1 commit into from
Oct 10, 2024
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: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ repos:
description: Check files with cargo clippy
entry: cargo clippy
language: system
args: ["--", "-D", "warnings"]
args: ["--all-targets", "--features", "python-bindings", "--", "-D", "warnings"]
types: [rust]
pass_filenames: false
10 changes: 4 additions & 6 deletions src/python_bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn build_regex_from_schema_py(
#[pyfunction(name = "to_regex")]
#[pyo3(signature = (json, whitespace_pattern=None))]
pub fn to_regex_py(json: Bound<PyDict>, whitespace_pattern: Option<&str>) -> PyResult<String> {
let json_value: Value = serde_pyobject::from_pyobject(json).unwrap();
let json_value: Value = serde_pyobject::from_pyobject(json)?;
json_schema::to_regex(&json_value, whitespace_pattern, &json_value)
.map_err(|e| PyValueError::new_err(e.to_string()))
}
Expand Down Expand Up @@ -173,13 +173,11 @@ pub fn create_fsm_index_end_to_end_py<'py>(

for (token_id, end_state) in token_ids_end_states {
if let Ok(Some(existing_dict)) = states_to_token_subsets.get_item(start_state) {
existing_dict.set_item(token_id, end_state).unwrap();
existing_dict.set_item(token_id, end_state)?;
} else {
let new_dict = PyDict::new_bound(py);
new_dict.set_item(token_id, end_state).unwrap();
states_to_token_subsets
.set_item(start_state, new_dict)
.unwrap();
new_dict.set_item(token_id, end_state)?;
states_to_token_subsets.set_item(start_state, new_dict)?;
}

if !seen.contains(&end_state) {
Expand Down
Loading