Skip to content

Commit 1f9fee3

Browse files
committed
fix ruff warnings
1 parent c3e014e commit 1f9fee3

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

asyncio/funcs.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,13 @@ def done(t, er):
168168
elif isinstance(ts[i].data, StopIteration):
169169
# Sub-task ran to completion, get its return value.
170170
ts[i] = ts[i].data.value
171-
else:
172-
# Sub-task had an exception.
173-
if return_exceptions:
174-
# Get the sub-task exception to return in the list of return values.
175-
ts[i] = ts[i].data
176-
elif isinstance(state, int):
177-
# Raise the sub-task exception, if there is not already an exception to raise.
178-
state = ts[i].data
171+
# Sub-task had an exception.
172+
elif return_exceptions:
173+
# Get the sub-task exception to return in the list of return values.
174+
ts[i] = ts[i].data
175+
elif isinstance(state, int):
176+
# Raise the sub-task exception, if there is not already an exception to raise.
177+
state = ts[i].data
179178

180179
# Either this gather was cancelled, or one of the sub-tasks raised an exception with
181180
# return_exceptions==False, so reraise the exception here.

asyncio/task.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,18 @@ def cancel(self):
198198
if self is core.cur_task:
199199
raise RuntimeError("can't cancel self")
200200
# If Task waits on another task then forward the cancel to the one it's waiting on.
201-
while isinstance(self.data, Task):
202-
self = self.data
201+
# CIRCUITPY-CHANGE: don't reassign self
202+
task = self
203+
while isinstance(task.data, Task):
204+
task = task.data
203205
# Reschedule Task as a cancelled task.
204-
if hasattr(self.data, "remove"):
206+
if hasattr(task.data, "remove"):
205207
# Not on the main running queue, remove the task from the queue it's on.
206-
self.data.remove(self)
207-
core._task_queue.push(self)
208-
elif core.ticks_diff(self.ph_key, core.ticks()) > 0:
208+
task.data.remove(task)
209+
core._task_queue.push(task)
210+
elif core.ticks_diff(task.ph_key, core.ticks()) > 0:
209211
# On the main running queue but scheduled in the future, so bring it forward to now.
210-
core._task_queue.remove(self)
211-
core._task_queue.push(self)
212-
self.data = core.CancelledError
212+
core._task_queue.remove(task)
213+
core._task_queue.push(task)
214+
task.data = core.CancelledError
213215
return True

asyncio/traceback.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def _print_traceback(traceback, limit=None, file=sys.stderr) -> List[str]:
2929
name = frame_code.co_name
3030
print(f' File "{filename}", line {line_number}, in {name}', file=file)
3131
traceback = traceback.tb_next
32-
n = n + 1
32+
# CIRCUITPY-CHANGE: use +=
33+
n += 1
3334
if limit is not None and n >= limit:
3435
break
3536

0 commit comments

Comments
 (0)