Skip to content

Commit 438bba9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 54f4669 commit 438bba9

48 files changed

Lines changed: 145 additions & 137 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def add_mapping(
321321

322322
# General information about the project.
323323
project = "Trio"
324-
copyright = "2017, Nathaniel J. Smith" # noqa: A001 # Name shadows builtin
324+
copyright = "2017, Nathaniel J. Smith" # ruff:ignore[builtin-variable-shadowing] # Name shadows builtin
325325
author = "Nathaniel J. Smith"
326326

327327
# The version info for the project you're documenting, acts as replacement for

pyproject.toml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,31 +146,31 @@ select = [
146146
"YTT", # flake8-2020
147147
]
148148
extend-ignore = [
149-
"A002", # builtin-argument-shadowing
150-
"ANN401", # any-type (mypy's `disallow_any_explicit` is better)
151-
"E402", # module-import-not-at-top-of-file (usually OS-specific)
152-
"E501", # line-too-long
153-
"F403", # undefined-local-with-import-star
154-
"F405", # undefined-local-with-import-star-usage
155-
"PERF203", # try-except-in-loop (not always possible to refactor)
156-
"PT012", # multiple statements in pytest.raises block
157-
"SIM117", # multiple-with-statements (messes up lots of context-based stuff and looks bad)
158-
"RUF067", # non-empty-init-module, since we need lots of logic in our __init__
149+
"builtin-argument-shadowing", # builtin-argument-shadowing
150+
"any-type", # any-type (mypy's `disallow_any_explicit` is better)
151+
"module-import-not-at-top-of-file", # module-import-not-at-top-of-file (usually OS-specific)
152+
"line-too-long", # line-too-long
153+
"undefined-local-with-import-star", # undefined-local-with-import-star
154+
"undefined-local-with-import-star-usage", # undefined-local-with-import-star-usage
155+
"try-except-in-loop", # try-except-in-loop (not always possible to refactor)
156+
"pytest-raises-with-multiple-statements", # multiple statements in pytest.raises block
157+
"multiple-with-statements", # multiple-with-statements (messes up lots of context-based stuff and looks bad)
158+
"non-empty-init-module", # non-empty-init-module, since we need lots of logic in our __init__
159159

160160
# conflicts with formatter (ruff recommends these be disabled)
161-
"COM812",
161+
"missing-trailing-comma",
162162
]
163163

164164
[tool.ruff.lint.per-file-ignores]
165165
# F401 is ignoring unused imports. For these particular files,
166166
# these are public APIs where we are importing everything we want
167167
# to export for public use.
168-
'src/trio/__init__.py' = ['F401']
169-
'src/trio/_core/__init__.py' = ['F401']
170-
'src/trio/abc.py' = ['F401', 'A005']
171-
'src/trio/lowlevel.py' = ['F401']
172-
'src/trio/socket.py' = ['F401', 'A005']
173-
'src/trio/testing/__init__.py' = ['F401']
168+
'src/trio/__init__.py' = ['unused-import']
169+
'src/trio/_core/__init__.py' = ['unused-import']
170+
'src/trio/abc.py' = ['unused-import', 'stdlib-module-shadowing']
171+
'src/trio/lowlevel.py' = ['unused-import']
172+
'src/trio/socket.py' = ['unused-import', 'stdlib-module-shadowing']
173+
'src/trio/testing/__init__.py' = ['unused-import']
174174

175175
# RUF029 is ignoring tests that are marked as async functions but
176176
# do not use an await in their function bodies. There are several
@@ -179,12 +179,12 @@ extend-ignore = [
179179
#
180180
# RUF069 is ignoring exact float comparison, because we use that
181181
# in combination with autojump clocks
182-
'src/trio/_tests/*.py' = ['RUF029', 'RUF069']
183-
'src/trio/_core/_tests/*.py' = ['RUF029', 'RUF069']
182+
'src/trio/_tests/*.py' = ['unused-async', 'float-equality-comparison']
183+
'src/trio/_core/_tests/*.py' = ['unused-async', 'float-equality-comparison']
184184
# A005 is ignoring modules that shadow stdlib modules.
185-
'src/trio/_abc.py' = ['A005']
186-
'src/trio/_socket.py' = ['A005']
187-
'src/trio/_ssl.py' = ['A005']
185+
'src/trio/_abc.py' = ['stdlib-module-shadowing']
186+
'src/trio/_socket.py' = ['stdlib-module-shadowing']
187+
'src/trio/_ssl.py' = ['stdlib-module-shadowing']
188188

189189
[tool.ruff.lint.isort]
190190
combine-as-imports = true

src/trio/_abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def deadline_to_sleep_time(self, deadline: float) -> float:
6666
"""
6767

6868

69-
class Instrument(ABC): # noqa: B024 # conceptually is ABC
69+
class Instrument(ABC): # ruff:ignore[abstract-base-class-without-abstract-method] # conceptually is ABC
7070
"""The interface for run loop instrumentation.
7171
7272
Instruments don't have to inherit from this abstract base class, and all

src/trio/_channel.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import sys
44
from collections import OrderedDict, deque
5-
from collections.abc import AsyncGenerator, Callable # noqa: TC003 # Needed for Sphinx
5+
from collections.abc import ( # ruff:ignore[typing-only-standard-library-import] # Needed for Sphinx
6+
AsyncGenerator,
7+
Callable,
8+
)
69
from contextlib import AbstractAsyncContextManager, asynccontextmanager
710
from functools import wraps
811
from math import inf
@@ -100,7 +103,7 @@ class open_memory_channel(tuple["MemorySendChannel[T]", "MemoryReceiveChannel[T]
100103

101104
def __new__( # type: ignore[misc] # "must return a subtype"
102105
cls,
103-
max_buffer_size: int | float, # noqa: PYI041
106+
max_buffer_size: int | float, # ruff:ignore[redundant-numeric-union]
104107
) -> tuple[MemorySendChannel[T], MemoryReceiveChannel[T]]:
105108
if max_buffer_size != inf and not isinstance(max_buffer_size, int):
106109
raise TypeError("max_buffer_size must be an integer or math.inf")
@@ -112,7 +115,7 @@ def __new__( # type: ignore[misc] # "must return a subtype"
112115
MemoryReceiveChannel[T]._create(state),
113116
)
114117

115-
def __init__(self, max_buffer_size: int | float) -> None: # noqa: PYI041
118+
def __init__(self, max_buffer_size: int | float) -> None: # ruff:ignore[redundant-numeric-union]
116119
...
117120

118121

@@ -621,7 +624,7 @@ async def _move_elems_to_channel(
621624
genexits_seen = 0
622625
for e in removed_exceptions:
623626
if isinstance(e, BaseExceptionGroup):
624-
removed_exceptions.extend(e.exceptions) # noqa: B909
627+
removed_exceptions.extend(e.exceptions) # ruff:ignore[loop-iterator-mutation]
625628
else:
626629
genexits_seen += 1
627630

src/trio/_core/_entry_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def run_cb(job: Job) -> None:
6565
sync_fn(*args)
6666
except BaseException as exc:
6767

68-
async def kill_everything( # noqa: RUF029 # await not used
68+
async def kill_everything( # ruff:ignore[unused-async] # await not used
6969
exc: BaseException,
7070
) -> NoReturn:
7171
raise exc

src/trio/_core/_ki.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ def remove(
129129
k: _IdRef[_KT],
130130
selfref: weakref.ref[
131131
WeakKeyIdentityDictionary[_KT, _VT]
132-
] = weakref.ref( # noqa: B008 # function-call-in-default-argument
132+
] = weakref.ref( # ruff:ignore[function-call-in-default-argument] # function-call-in-default-argument
133133
self,
134134
),
135135
) -> None:
136136
self = selfref()
137137
if self is not None:
138-
try: # noqa: SIM105 # suppressible-exception
138+
try: # ruff:ignore[suppressible-exception] # suppressible-exception
139139
del self._data[k]
140140
except KeyError:
141141
pass

src/trio/_core/_parking_lot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def abort_fn(_: _core.RaiseCancelT) -> _core.Abort:
189189

190190
await _core.wait_task_rescheduled(abort_fn)
191191

192-
def _pop_several(self, count: int | float) -> Iterator[Task]: # noqa: PYI041
192+
def _pop_several(self, count: int | float) -> Iterator[Task]: # ruff:ignore[redundant-numeric-union]
193193
if isinstance(count, float):
194194
if math.isinf(count):
195195
count = len(self._parked)
@@ -202,7 +202,7 @@ def _pop_several(self, count: int | float) -> Iterator[Task]: # noqa: PYI041
202202
yield task
203203

204204
@_core.enable_ki_protection
205-
def unpark(self, *, count: int | float = 1) -> list[Task]: # noqa: PYI041
205+
def unpark(self, *, count: int | float = 1) -> list[Task]: # ruff:ignore[redundant-numeric-union]
206206
"""Unpark one or more tasks.
207207
208208
This wakes up ``count`` tasks that are blocked in :meth:`park`. If
@@ -227,7 +227,7 @@ def repark(
227227
self,
228228
new_lot: ParkingLot,
229229
*,
230-
count: int | float = 1, # noqa: PYI041
230+
count: int | float = 1, # ruff:ignore[redundant-numeric-union]
231231
) -> None:
232232
"""Move parked tasks from one :class:`ParkingLot` object to another.
233233

src/trio/_core/_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def _count_context_run_tb_frames() -> int:
158158

159159
def function_with_unique_name_xyzzy() -> NoReturn:
160160
try:
161-
1 / 0 # noqa: B018 # We need a ZeroDivisionError to fire
161+
1 / 0 # ruff:ignore[useless-expression] # We need a ZeroDivisionError to fire
162162
except ZeroDivisionError:
163163
raise
164164
else: # pragma: no cover
@@ -961,7 +961,7 @@ def cancel_called(self) -> bool:
961961
cancelled, then :attr:`cancelled_caught` is usually more
962962
appropriate.
963963
"""
964-
if ( # noqa: SIM102 # collapsible-if but this way is nicer
964+
if ( # ruff:ignore[collapsible-if] # collapsible-if but this way is nicer
965965
self._cancel_status is not None or not self._has_been_entered
966966
):
967967
# Scope is active or not yet entered: make sure cancel_called

src/trio/_core/_tests/test_asyncgen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def example(cause: str) -> AsyncGenerator[int, None]:
2323
try:
2424
with contextlib.suppress(GeneratorExit):
2525
# we *want* to test what happens to delayed `await`
26-
yield 42 # noqa: ASYNC119
26+
yield 42 # ruff:ignore[yield-in-context-manager-in-async-generator]
2727
await _core.checkpoint()
2828
except _core.Cancelled:
2929
assert "exhausted" not in cause
@@ -44,7 +44,7 @@ async def example(cause: str) -> AsyncGenerator[int, None]:
4444

4545
async def async_main() -> None:
4646
# GC'ed before exhausted
47-
with pytest.warns( # noqa: PT031
47+
with pytest.warns( # ruff:ignore[pytest-warns-with-multiple-statements]
4848
ResourceWarning,
4949
match="Async generator.*collected before.*exhausted",
5050
):
@@ -281,12 +281,12 @@ async def well_behaved() -> AsyncGenerator[int, None]:
281281
# noqas because we *want* to test delayed yield/await!
282282
async def yields_after_yield() -> AsyncGenerator[int, None]:
283283
with pytest.raises(GeneratorExit):
284-
yield 42 # noqa: ASYNC119
284+
yield 42 # ruff:ignore[yield-in-context-manager-in-async-generator]
285285
yield 100
286286

287287
async def awaits_after_yield() -> AsyncGenerator[int, None]:
288288
with pytest.raises(GeneratorExit):
289-
yield 42 # noqa: ASYNC119
289+
yield 42 # ruff:ignore[yield-in-context-manager-in-async-generator]
290290
await _core.cancel_shielded_checkpoint()
291291

292292
with restore_unraisablehook():

src/trio/_core/_tests/test_guest_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ async def abandoned_main(in_host: InHost) -> None:
437437
with pytest.raises(ZeroDivisionError):
438438
trivial_guest_run(abandoned_main)
439439

440-
with pytest.warns( # noqa: PT031
440+
with pytest.warns( # ruff:ignore[pytest-warns-with-multiple-statements]
441441
RuntimeWarning,
442442
match="Trio guest run got abandoned",
443443
):

0 commit comments

Comments
 (0)