Skip to content

Commit

Permalink
Rustfmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Apr 15, 2024
1 parent 0787e67 commit 56cb096
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
6 changes: 1 addition & 5 deletions bindings/python/src/decoders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,7 @@ impl PyMetaspaceDec {

#[new]
#[pyo3(signature = (replacement = '▁', prepend_scheme = String::from("always"), split = true), text_signature = "(self, replacement = \"\", prepend_scheme = \"always\", split = True)")]
fn new(
replacement: char,
prepend_scheme: String,
split: bool,
) -> PyResult<(Self, PyDecoder)> {
fn new(replacement: char, prepend_scheme: String, split: bool) -> PyResult<(Self, PyDecoder)> {
let prepend_scheme = from_string(prepend_scheme)?;
Ok((
PyMetaspaceDec {},
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern "C" fn child_after_fork() {

/// Tokenizers Module
#[pymodule]
pub fn tokenizers(m: &Bound<'_ , PyModule>) -> PyResult<()> {
pub fn tokenizers(m: &Bound<'_, PyModule>) -> PyResult<()> {
let _ = env_logger::try_init_from_env("TOKENIZERS_LOG");

// Register the fork callback
Expand Down
5 changes: 4 additions & 1 deletion bindings/python/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ impl PyModel {
pub struct PyBPE {}

impl PyBPE {
fn with_builder(mut builder: BpeBuilder, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<(Self, PyModel)> {
fn with_builder(
mut builder: BpeBuilder,
kwargs: Option<&Bound<'_, PyDict>>,
) -> PyResult<(Self, PyModel)> {
if let Some(kwargs) = kwargs {
for (key, value) in kwargs {
let key: &str = key.extract()?;
Expand Down
5 changes: 4 additions & 1 deletion bindings/python/src/processors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ pub struct PyByteLevel {}
impl PyByteLevel {
#[new]
#[pyo3(signature = (trim_offsets = None, **_kwargs), text_signature = "(self, trim_offsets=True)")]
fn new(trim_offsets: Option<bool>, _kwargs: Option<&Bound<'_, PyDict>>) -> (Self, PyPostProcessor) {
fn new(
trim_offsets: Option<bool>,
_kwargs: Option<&Bound<'_, PyDict>>,
) -> (Self, PyPostProcessor) {
let mut byte_level = ByteLevel::default();

if let Some(to) = trim_offsets {
Expand Down
8 changes: 6 additions & 2 deletions bindings/python/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,11 @@ impl PyTokenizer {
#[pyo3(
text_signature = "(self, max_length, stride=0, strategy='longest_first', direction='right')"
)]
fn enable_truncation(&mut self, max_length: usize, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<()> {
fn enable_truncation(
&mut self,
max_length: usize,
kwargs: Option<&Bound<'_, PyDict>>,
) -> PyResult<()> {
let mut params = TruncationParams {
max_length,
..Default::default()
Expand Down Expand Up @@ -887,7 +891,7 @@ impl PyTokenizer {
/// (:obj:`dict`, `optional`):
/// A dict with the current padding parameters if padding is enabled
#[getter]
fn get_padding<'py>(&self, py: Python<'py>) -> PyResult<Option<Bound<'py, PyDict>>> {
fn get_padding<'py>(&self, py: Python<'py>) -> PyResult<Option<Bound<'py, PyDict>>> {
self.tokenizer.get_padding().map_or(Ok(None), |params| {
let dict = PyDict::new_bound(py);

Expand Down
7 changes: 4 additions & 3 deletions bindings/python/src/utils/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ where
}

match unsafe {
Bound::from_owned_ptr_or_opt(py, pyo3::ffi::PyIter_Next(
self.iter.as_ref().unwrap().bind(py).as_ptr(),
))
Bound::from_owned_ptr_or_opt(
py,
pyo3::ffi::PyIter_Next(self.iter.as_ref().unwrap().bind(py).as_ptr()),
)
} {
Some(obj) => self.buffer.extend((self.converter)(obj)),
None => {
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/src/utils/normalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn map(normalized: &mut NormalizedString, func: &Bound<'_, PyAny>) -> PyResult<(
Err(exceptions::PyTypeError::new_err(err))
} else {
normalized.map(|c| {
let c: String= func
let c: String = func
.call1((c.to_string(),))
.expect(err)
.extract()
Expand Down

0 comments on commit 56cb096

Please sign in to comment.