From 6547fd883209f38ce6c88e9bc8e30d0b792b5e60 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 14 Nov 2023 16:05:14 +0100 Subject: [PATCH] nits format --- bindings/python/src/pre_tokenizers.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/bindings/python/src/pre_tokenizers.rs b/bindings/python/src/pre_tokenizers.rs index e9f0fb954..e5dad363c 100644 --- a/bindings/python/src/pre_tokenizers.rs +++ b/bindings/python/src/pre_tokenizers.rs @@ -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, 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); @@ -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, + ))); } };