Skip to content

Commit

Permalink
nits format
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurZucker committed Nov 14, 2023
1 parent 20b0cf4 commit 6547fd8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions bindings/python/src/pre_tokenizers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,19 +500,22 @@ impl PyMetaspace {
}
.to_string()
}
const UNKNOWN_VARIANT_ERROR_MESSAGE: &str =
"is an unknown variant, should be one of ['First', 'Never', 'Always']";

#[setter]
fn set_prepend_scheme(self_: PyRef<Self>, prepend_scheme: &str) -> PyResult<()> {
// Assuming Metaspace has a method to set the prepend_scheme from a string
let scheme = match prepend_scheme.as_str() {
"first" => PrependScheme::First,
"never" => PrependScheme::Never,
"always" => PrependScheme::Always,
let scheme = match prepend_scheme {
"First" => PrependScheme::First,
"Never" => PrependScheme::Never,
"Always" => PrependScheme::Always,
_ => {
return Err(exceptions::PyValueError::new_err(format!(
"Unknown variant: {}, should be one of First, Never, Always",
prepend_scheme
)))
"{} {}",
prepend_scheme,
Self::UNKNOWN_VARIANT_ERROR_MESSAGE,
)));
}
};
setter!(self_, Metaspace, @set_prepend_scheme, scheme);
Expand Down Expand Up @@ -543,9 +546,10 @@ impl PyMetaspace {
"always" => PrependScheme::Always,
_ => {
return Err(exceptions::PyValueError::new_err(format!(
"Unknown variant: {}",
prepend_scheme_value
)))
"{} {}",
prepend_scheme,
Self::UNKNOWN_VARIANT_ERROR_MESSAGE,
)));
}
};

Expand Down

0 comments on commit 6547fd8

Please sign in to comment.