Skip to content

Commit

Permalink
Review rust lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Feb 13, 2024
1 parent 459a864 commit 4e1c05c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,21 @@ lint-rust:
-D warnings \
-W clippy::pedantic \
-W clippy::dbg_macro \
-W clippy::print_stdout \
-A clippy::cast-possible-truncation \
-A clippy::cast-possible-wrap \
-A clippy::cast-precision-loss \
-A clippy::cast-sign-loss \
-A clippy::declare-interior-mutable-const \
-A clippy::float-cmp \
-A clippy::fn-params-excessive-bools \
-A clippy::if-not-else \
-A clippy::inline-always \
-A clippy::manual-let-else \
-A clippy::match-bool \
-A clippy::match-same-arms \
-A clippy::missing-errors-doc \
-A clippy::missing-panics-doc \
-A clippy::module-name-repetitions \
-A clippy::must-use-candidate \
-A clippy::needless-pass-by-value \
-A clippy::no-effect-underscore-binding \
-A clippy::similar-names \
-A clippy::single-match-else \
-A clippy::struct-excessive-bools \
-A clippy::too-many-arguments \
-A clippy::too-many-lines \
-A clippy::type-complexity \
-A clippy::unnecessary-wraps \
-A clippy::unused-self \
-A clippy::used-underscore-binding \
-A clippy::wrong-self-convention

.PHONY: lint
Expand Down
3 changes: 1 addition & 2 deletions src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ impl PyFutureAwaitable {
}

#[pyo3(signature = (cb, context=None))]
fn add_done_callback(mut pyself: PyRefMut<'_, Self>, cb: PyObject, context: Option<PyObject>) -> PyResult<()> {
fn add_done_callback(mut pyself: PyRefMut<'_, Self>, cb: PyObject, context: Option<PyObject>) {
pyself.callback = Some(cb);
if let Some(spawner) = pyself.fut_spawner.take() {
(spawner)(context, pyself.cancel_tx.clone(), pyself.into());
}
Ok(())
}

#[allow(unused)]
Expand Down
3 changes: 1 addition & 2 deletions src/rsgi/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl WebsocketInboundTextMessage {
#[pymethods]
impl RSGIWebsocketProtocol {
#[pyo3(signature = (status=None))]
pub fn close(&mut self, py: Python, status: Option<i32>) -> PyResult<()> {
pub fn close(&mut self, py: Python, status: Option<i32>) {
self.status = status.unwrap_or(0);
if let Some(tx) = self.tx.take() {
let mut handle = None;
Expand All @@ -361,7 +361,6 @@ impl RSGIWebsocketProtocol {

let _ = tx.send((self.status, self.consumed(), handle));
}
Ok(())
}

fn accept<'p>(&mut self, py: Python<'p>) -> PyResult<&'p PyAny> {
Expand Down
1 change: 1 addition & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ where
Ok(aw.into_py(py).into_ref(py))
}

#[allow(clippy::unnecessary_wraps)]
#[inline(always)]
pub(crate) fn empty_future_into_py(py: Python) -> PyResult<&PyAny> {
Ok(PyEmptyAwaitable {}.into_py(py).into_ref(py))
Expand Down
8 changes: 4 additions & 4 deletions src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ pub struct ListenerHolder {
impl ListenerHolder {
#[cfg(unix)]
#[new]
pub fn new(fd: i32) -> PyResult<Self> {
pub fn new(fd: i32) -> Self {
let socket = unsafe { TcpListener::from_raw_fd(fd) };
Ok(Self { socket })
Self { socket }
}

#[cfg(windows)]
#[new]
pub fn new(fd: u64) -> PyResult<Self> {
pub fn new(fd: u64) -> Self {
let socket = unsafe { TcpListener::from_raw_socket(fd) };
Ok(Self { socket })
Self { socket }
}

#[classmethod]
Expand Down
4 changes: 2 additions & 2 deletions src/workers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub(crate) struct WorkerSignal {
#[pymethods]
impl WorkerSignal {
#[new]
fn new() -> PyResult<Self> {
fn new() -> Self {
let (tx, rx) = tokio::sync::watch::channel(false);
Ok(Self { rx: Some(rx), tx })
Self { rx: Some(rx), tx }
}

fn set(&self) {
Expand Down

0 comments on commit 4e1c05c

Please sign in to comment.