Fix clippy warnings

This commit is contained in:
Anthony MOI
2021-03-10 20:26:39 -05:00
committed by Anthony MOI
parent ee95e7f0cd
commit 56a9196030
9 changed files with 106 additions and 117 deletions

View File

@ -102,10 +102,10 @@ impl Normalizer for PyNormalizer {
#[pymethods]
impl PyNormalizer {
#[staticmethod]
fn custom(obj: PyObject) -> PyResult<Self> {
Ok(Self {
fn custom(obj: PyObject) -> Self {
Self {
normalizer: PyNormalizerWrapper::Custom(CustomNormalizer::new(obj)).into(),
})
}
}
fn __getstate__(&self, py: Python) -> PyResult<PyObject> {
@ -279,10 +279,10 @@ impl PyBertNormalizer {
handle_chinese_chars: bool,
strip_accents: Option<bool>,
lowercase: bool,
) -> PyResult<(Self, PyNormalizer)> {
) -> (Self, PyNormalizer) {
let normalizer =
BertNormalizer::new(clean_text, handle_chinese_chars, strip_accents, lowercase);
Ok((PyBertNormalizer {}, normalizer.into()))
(PyBertNormalizer {}, normalizer.into())
}
}
@ -293,8 +293,8 @@ pub struct PyNFD {}
#[pymethods]
impl PyNFD {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyNFD {}, PyNormalizer::new(NFD.into())))
fn new() -> (Self, PyNormalizer) {
(PyNFD {}, PyNormalizer::new(NFD.into()))
}
}
@ -305,8 +305,8 @@ pub struct PyNFKD {}
#[pymethods]
impl PyNFKD {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyNFKD {}, NFKD.into()))
fn new() -> (Self, PyNormalizer) {
(PyNFKD {}, NFKD.into())
}
}
@ -317,8 +317,8 @@ pub struct PyNFC {}
#[pymethods]
impl PyNFC {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyNFC {}, NFC.into()))
fn new() -> (Self, PyNormalizer) {
(PyNFC {}, NFC.into())
}
}
@ -329,8 +329,8 @@ pub struct PyNFKC {}
#[pymethods]
impl PyNFKC {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyNFKC {}, NFKC.into()))
fn new() -> (Self, PyNormalizer) {
(PyNFKC {}, NFKC.into())
}
}
@ -360,8 +360,8 @@ impl PySequence {
))
}
fn __getnewargs__<'p>(&self, py: Python<'p>) -> PyResult<&'p PyTuple> {
Ok(PyTuple::new(py, &[PyList::empty(py)]))
fn __getnewargs__<'p>(&self, py: Python<'p>) -> &'p PyTuple {
PyTuple::new(py, &[PyList::empty(py)])
}
}
@ -379,8 +379,8 @@ pub struct PyLowercase {}
#[pymethods]
impl PyLowercase {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyLowercase {}, Lowercase.into()))
fn new() -> (Self, PyNormalizer) {
(PyLowercase {}, Lowercase.into())
}
}
@ -412,8 +412,8 @@ impl PyStrip {
#[new]
#[args(left = "true", right = "true")]
fn new(left: bool, right: bool) -> PyResult<(Self, PyNormalizer)> {
Ok((PyStrip {}, Strip::new(left, right).into()))
fn new(left: bool, right: bool) -> (Self, PyNormalizer) {
(PyStrip {}, Strip::new(left, right).into())
}
}
@ -424,8 +424,8 @@ pub struct PyStripAccents {}
#[pymethods]
impl PyStripAccents {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyStripAccents {}, StripAccents.into()))
fn new() -> (Self, PyNormalizer) {
(PyStripAccents {}, StripAccents.into())
}
}
@ -436,8 +436,8 @@ pub struct PyNmt {}
#[pymethods]
impl PyNmt {
#[new]
fn new() -> PyResult<(Self, PyNormalizer)> {
Ok((PyNmt {}, Nmt.into()))
fn new() -> (Self, PyNormalizer) {
(PyNmt {}, Nmt.into())
}
}