Skip to content

Commit 2d5744b

Browse files
committed
style(python): rustfmt the response module
1 parent 2b68541 commit 2d5744b

1 file changed

Lines changed: 39 additions & 37 deletions

File tree

impit-python/src/response.rs

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -141,43 +141,44 @@ impl PyResponseAsyncBytesIterator {
141141

142142
let parent_response = self.parent_response.as_ref().map(|p| p.clone_ref(py));
143143

144-
let future = pyo3_async_runtimes::tokio::future_into_py::<_, Py<PyBytes>>(py, async move {
145-
let chunk_result = {
146-
let mut stream_guard = stream_arc.lock().await;
147-
if let Some(stream) = stream_guard.as_mut() {
148-
stream.next().await
149-
} else {
150-
None
151-
}
152-
};
153-
match chunk_result {
154-
Some(Ok(chunk)) => Ok(Python::attach(|py| PyBytes::new(py, &chunk).unbind())),
155-
Some(Err(e)) => {
156-
if let Some(parent) = parent_response {
157-
Python::attach(|py| {
158-
if let Ok(mut parent_ref) = parent.try_borrow_mut(py) {
159-
parent_ref.inner_state = InnerResponseState::StreamingClosed;
160-
parent_ref.is_stream_consumed = true;
161-
parent_ref.is_closed = true;
162-
}
163-
});
144+
let future =
145+
pyo3_async_runtimes::tokio::future_into_py::<_, Py<PyBytes>>(py, async move {
146+
let chunk_result = {
147+
let mut stream_guard = stream_arc.lock().await;
148+
if let Some(stream) = stream_guard.as_mut() {
149+
stream.next().await
150+
} else {
151+
None
164152
}
165-
Err(ImpitPyError(ImpitError::from(e, None)).into())
166-
}
167-
None => {
168-
if let Some(parent) = parent_response {
169-
Python::attach(|py| {
170-
if let Ok(mut parent_ref) = parent.try_borrow_mut(py) {
171-
parent_ref.inner_state = InnerResponseState::StreamingClosed;
172-
parent_ref.is_stream_consumed = true;
173-
parent_ref.is_closed = true;
174-
}
175-
});
153+
};
154+
match chunk_result {
155+
Some(Ok(chunk)) => Ok(Python::attach(|py| PyBytes::new(py, &chunk).unbind())),
156+
Some(Err(e)) => {
157+
if let Some(parent) = parent_response {
158+
Python::attach(|py| {
159+
if let Ok(mut parent_ref) = parent.try_borrow_mut(py) {
160+
parent_ref.inner_state = InnerResponseState::StreamingClosed;
161+
parent_ref.is_stream_consumed = true;
162+
parent_ref.is_closed = true;
163+
}
164+
});
165+
}
166+
Err(ImpitPyError(ImpitError::from(e, None)).into())
167+
}
168+
None => {
169+
if let Some(parent) = parent_response {
170+
Python::attach(|py| {
171+
if let Ok(mut parent_ref) = parent.try_borrow_mut(py) {
172+
parent_ref.inner_state = InnerResponseState::StreamingClosed;
173+
parent_ref.is_stream_consumed = true;
174+
parent_ref.is_closed = true;
175+
}
176+
});
177+
}
178+
Err(pyo3::exceptions::PyStopAsyncIteration::new_err(""))
176179
}
177-
Err(pyo3::exceptions::PyStopAsyncIteration::new_err(""))
178180
}
179-
}
180-
})?;
181+
})?;
181182

182183
Ok(future)
183184
}
@@ -407,9 +408,10 @@ impl ImpitPyResponse {
407408
})),
408409
InnerResponseState::Unread => {
409410
if let Some(response) = response_option {
410-
let content = response.bytes().await.map_err(|_| {
411-
ImpitPyError(impit::errors::ImpitError::NetworkError)
412-
})?;
411+
let content = response
412+
.bytes()
413+
.await
414+
.map_err(|_| ImpitPyError(impit::errors::ImpitError::NetworkError))?;
413415

414416
Ok(Python::attach(|py| {
415417
let mut slf_ref = slf.borrow_mut(py);

0 commit comments

Comments
 (0)