Skip to content

Commit 215fac1

Browse files
committed
Merge remote-tracking branch 'origin/main' into drop-3.8-support
2 parents c2d5954 + c47758c commit 215fac1

Some content is hidden

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

42 files changed

+131
-100
lines changed

docs-requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
sphinx >= 6.0
44
jinja2
55
# >= is necessary to prevent `uv` from selecting a `Sphinx` version this does not support
6-
sphinx_rtd_theme >= 2
6+
sphinx_rtd_theme >= 3
77
sphinxcontrib-jquery
88
sphinxcontrib-trio
99
towncrier

docs-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ sphinx-codeautolink==0.15.2
7979
# via -r docs-requirements.in
8080
sphinx-hoverxref==1.4.1
8181
# via -r docs-requirements.in
82-
sphinx-rtd-theme==2.0.0
82+
sphinx-rtd-theme==3.0.0
8383
# via -r docs-requirements.in
8484
sphinxcontrib-applehelp==2.0.0
8585
# via sphinx

docs/source/conf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def setup(app: Sphinx) -> None:
201201
app.connect("source-read", on_read_source)
202202

203203

204+
# Our docs use the READTHEDOCS variable, so copied from:
205+
# https://about.readthedocs.com/blog/2024/07/addons-by-default/
206+
if os.environ.get("READTHEDOCS", "") == "True":
207+
if "html_context" not in globals():
208+
html_context = {}
209+
html_context["READTHEDOCS"] = True
210+
204211
# -- General configuration ------------------------------------------------
205212

206213
# If your documentation needs a minimal Sphinx version, state it here.
@@ -374,10 +381,7 @@ def add_mapping(
374381
# We have to set this ourselves, not only because it's useful for local
375382
# testing, but also because if we don't then RTD will throw away our
376383
# html_theme_options.
377-
import sphinx_rtd_theme
378-
379384
html_theme = "sphinx_rtd_theme"
380-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
381385

382386
# Theme options are theme-specific and customize the look and feel of a theme
383387
# further. For a list of options available for each theme, see the

notes-to-self/how-does-windows-so-reuseaddr-work.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ def table_entry(mode1, bind_type1, mode2, bind_type2):
4949
"""
5050
second bind
5151
| """
52-
+ " | ".join(["%-19s" % mode for mode in modes]),
52+
+ " | ".join(f"{mode:<19}" for mode in modes),
5353
)
5454

5555
print(""" """, end="")
5656
for _ in modes:
57-
print(" | " + " | ".join(["%8s" % bind_type for bind_type in bind_types]), end="")
57+
print(
58+
" | " + " | ".join(f"{bind_type:>8}" for bind_type in bind_types),
59+
end="",
60+
)
5861

5962
print(
6063
"""
@@ -72,5 +75,5 @@ def table_entry(mode1, bind_type1, mode2, bind_type2):
7275
# print(mode1, bind_type1, mode2, bind_type2, entry)
7376
print(
7477
f"{mode1:>19} | {bind_type1:>8} | "
75-
+ " | ".join(["%8s" % entry for entry in row]),
78+
+ " | ".join(f"{entry:>8}" for entry in row),
7679
)

notes-to-self/socket-scaling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def pt(desc, *, count=total, item="socket"):
3232
now = time.perf_counter()
3333
total_ms = (now - last_time) * 1000
3434
per_us = total_ms * 1000 / count
35-
print(f"{desc}: {total_ms:.2f} ms total, {per_us:.2f} µs/{item}")
35+
print(f"{desc}: {total_ms:.2f} ms total, {per_us:.2f} μs/{item}")
3636
last_time = now
3737

3838
print(f"\n-- {total} sockets --")

notes-to-self/thread-dispatch-bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
in_q.put(lambda: None)
3131
out_q.get()
3232
end = time.monotonic()
33-
print(f"{(end - start) / COUNT * 1e6:.2f} µs/job")
33+
print(f"{(end - start) / COUNT * 1e6:.2f} μs/job")
3434

3535

3636
main()

notes-to-self/trivial-err.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
sys.stderr = sys.stdout
66

77

8-
async def child1():
8+
async def child1(): # noqa: RUF029 # async not required
99
raise ValueError
1010

1111

@@ -15,11 +15,11 @@ async def child2():
1515
nursery.start_soon(grandchild2)
1616

1717

18-
async def grandchild1():
18+
async def grandchild1(): # noqa: RUF029 # async not required
1919
raise KeyError
2020

2121

22-
async def grandchild2():
22+
async def grandchild2(): # noqa: RUF029 # async not required
2323
raise NameError("Bob")
2424

2525

notes-to-self/trivial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import trio
22

33

4-
async def foo():
4+
async def foo(): # noqa: RUF029 # await not used
55
print("in foo!")
66
return 3
77

pyproject.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ extend-exclude = [
100100
]
101101

102102
[tool.ruff.lint]
103+
preview = true
103104
allowed-confusables = [""]
104105

105106
select = [
@@ -145,10 +146,20 @@ extend-ignore = [
145146
# to export for public use.
146147
'src/trio/__init__.py' = ['F401']
147148
'src/trio/_core/__init__.py' = ['F401']
148-
'src/trio/abc.py' = ['F401']
149+
'src/trio/abc.py' = ['F401', 'A005']
149150
'src/trio/lowlevel.py' = ['F401']
150-
'src/trio/socket.py' = ['F401']
151+
'src/trio/socket.py' = ['F401', 'A005']
151152
'src/trio/testing/__init__.py' = ['F401']
153+
# RUF029 is ignoring tests that are marked as async functions but
154+
# do not use an await in their function bodies. There are several
155+
# places where internal trio synchronous code relies on being
156+
# called from an async function, where current task is set up.
157+
'src/trio/_tests/*.py' = ['RUF029']
158+
'src/trio/_core/_tests/*.py' = ['RUF029']
159+
# A005 is ignoring modules that shadow stdlib modules.
160+
'src/trio/_abc.py' = ['A005']
161+
'src/trio/_socket.py' = ['A005']
162+
'src/trio/_ssl.py' = ['A005']
152163

153164
[tool.ruff.lint.isort]
154165
combine-as-imports = true

src/trio/_core/_entry_queue.py

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

68-
async def kill_everything(exc: BaseException) -> NoReturn:
68+
async def kill_everything( # noqa: RUF029 # await not used
69+
exc: BaseException,
70+
) -> NoReturn:
6971
raise exc
7072

7173
try:
@@ -140,7 +142,7 @@ def run_sync_soon(
140142
# wakeup call might trigger an OSError b/c the IO manager has
141143
# already been shut down.
142144
if idempotent:
143-
self.idempotent_queue[(sync_fn, args)] = None
145+
self.idempotent_queue[sync_fn, args] = None
144146
else:
145147
self.queue.append((sync_fn, args))
146148
self.wakeup.wakeup_thread_and_signal_safe()

0 commit comments

Comments
 (0)