Skip to content

Commit 571868c

Browse files
authored
Merge branch 'master' into dependabot/pip/urllib3-1.26.13
2 parents 9078da3 + 55117ad commit 571868c

51 files changed

Lines changed: 182 additions & 139 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: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# Trio documentation build configuration file, created by
54
# sphinx-quickstart on Sat Jan 21 19:11:14 2017.
@@ -19,17 +18,20 @@
1918
#
2019
import os
2120
import sys
21+
2222
# For our local_customization module
23-
sys.path.insert(0, os.path.abspath('.'))
23+
sys.path.insert(0, os.path.abspath("."))
2424
# For trio itself
25-
sys.path.insert(0, os.path.abspath('../..'))
25+
sys.path.insert(0, os.path.abspath("../.."))
2626

2727
# https://docs.readthedocs.io/en/stable/builds.html#build-environment
2828
if "READTHEDOCS" in os.environ:
2929
import glob
30+
3031
if glob.glob("../../newsfragments/*.*.rst"):
3132
print("-- Found newsfragments; running towncrier --", flush=True)
3233
import subprocess
34+
3335
subprocess.run(
3436
["towncrier", "--yes", "--date", "not released yet"],
3537
cwd="../..",
@@ -66,6 +68,7 @@
6668
def setup(app):
6769
app.add_css_file("hackrtd.css")
6870

71+
6972
# -- General configuration ------------------------------------------------
7073

7174
# If your documentation needs a minimal Sphinx version, state it here.
@@ -76,45 +79,46 @@ def setup(app):
7679
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
7780
# ones.
7881
extensions = [
79-
'sphinx.ext.autodoc',
80-
'sphinx.ext.intersphinx',
81-
'sphinx.ext.coverage',
82-
'sphinx.ext.napoleon',
83-
'sphinxcontrib_trio',
84-
'local_customization',
82+
"sphinx.ext.autodoc",
83+
"sphinx.ext.intersphinx",
84+
"sphinx.ext.coverage",
85+
"sphinx.ext.napoleon",
86+
"sphinxcontrib_trio",
87+
"local_customization",
8588
]
8689

8790
intersphinx_mapping = {
88-
"python": ('https://docs.python.org/3', None),
89-
"outcome": ('https://outcome.readthedocs.io/en/latest/', None),
90-
"pyopenssl": ('https://www.pyopenssl.org/en/stable/', None),
91+
"python": ("https://docs.python.org/3", None),
92+
"outcome": ("https://outcome.readthedocs.io/en/latest/", None),
93+
"pyopenssl": ("https://www.pyopenssl.org/en/stable/", None),
9194
}
9295

9396
autodoc_member_order = "bysource"
9497

9598
# Add any paths that contain templates here, relative to this directory.
96-
templates_path = ['_templates']
99+
templates_path = ["_templates"]
97100

98101
# The suffix(es) of source filenames.
99102
# You can specify multiple suffix as a list of string:
100103
#
101104
# source_suffix = ['.rst', '.md']
102-
source_suffix = '.rst'
105+
source_suffix = ".rst"
103106

104107
# The master toctree document.
105-
master_doc = 'index'
108+
master_doc = "index"
106109

107110
# General information about the project.
108-
project = 'Trio'
109-
copyright = '2017, Nathaniel J. Smith'
110-
author = 'Nathaniel J. Smith'
111+
project = "Trio"
112+
copyright = "2017, Nathaniel J. Smith"
113+
author = "Nathaniel J. Smith"
111114

112115
# The version info for the project you're documenting, acts as replacement for
113116
# |version| and |release|, also used in various other places throughout the
114117
# built documents.
115118
#
116119
# The short X.Y version.
117120
import trio
121+
118122
version = trio.__version__
119123
# The full version, including alpha/beta/rc tags.
120124
release = version
@@ -136,9 +140,9 @@ def setup(app):
136140
exclude_patterns = []
137141

138142
# The name of the Pygments (syntax highlighting) style to use.
139-
pygments_style = 'default'
143+
pygments_style = "default"
140144

141-
highlight_language = 'python3'
145+
highlight_language = "python3"
142146

143147
# If true, `todo` and `todoList` produce output, else they produce nothing.
144148
todo_include_todos = False
@@ -153,13 +157,14 @@ def setup(app):
153157
# The theme to use for HTML and HTML Help pages. See the documentation for
154158
# a list of builtin themes.
155159
#
156-
#html_theme = 'alabaster'
160+
# html_theme = 'alabaster'
157161

158162
# We have to set this ourselves, not only because it's useful for local
159163
# testing, but also because if we don't then RTD will throw away our
160164
# html_theme_options.
161165
import sphinx_rtd_theme
162-
html_theme = 'sphinx_rtd_theme'
166+
167+
html_theme = "sphinx_rtd_theme"
163168
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
164169

165170
# Theme options are theme-specific and customize the look and feel of a theme
@@ -174,19 +179,19 @@ def setup(app):
174179
# versions/settings...
175180
"navigation_depth": 4,
176181
"logo_only": True,
177-
'prev_next_buttons_location': 'both'
182+
"prev_next_buttons_location": "both",
178183
}
179184

180185
# Add any paths that contain custom static files (such as style sheets) here,
181186
# relative to this directory. They are copied after the builtin static files,
182187
# so a file named "default.css" will overwrite the builtin "default.css".
183-
html_static_path = ['_static']
188+
html_static_path = ["_static"]
184189

185190

186191
# -- Options for HTMLHelp output ------------------------------------------
187192

188193
# Output file base name for HTML help builder.
189-
htmlhelp_basename = 'Triodoc'
194+
htmlhelp_basename = "Triodoc"
190195

191196

192197
# -- Options for LaTeX output ---------------------------------------------
@@ -195,15 +200,12 @@ def setup(app):
195200
# The paper size ('letterpaper' or 'a4paper').
196201
#
197202
# 'papersize': 'letterpaper',
198-
199203
# The font size ('10pt', '11pt' or '12pt').
200204
#
201205
# 'pointsize': '10pt',
202-
203206
# Additional stuff for the LaTeX preamble.
204207
#
205208
# 'preamble': '',
206-
207209
# Latex figure (float) alignment
208210
#
209211
# 'figure_align': 'htbp',
@@ -213,19 +215,15 @@ def setup(app):
213215
# (source start file, target name, title,
214216
# author, documentclass [howto, manual, or own class]).
215217
latex_documents = [
216-
(master_doc, 'Trio.tex', 'Trio Documentation',
217-
'Nathaniel J. Smith', 'manual'),
218+
(master_doc, "Trio.tex", "Trio Documentation", "Nathaniel J. Smith", "manual"),
218219
]
219220

220221

221222
# -- Options for manual page output ---------------------------------------
222223

223224
# One entry per manual page. List of tuples
224225
# (source start file, name, description, authors, manual section).
225-
man_pages = [
226-
(master_doc, 'trio', 'Trio Documentation',
227-
[author], 1)
228-
]
226+
man_pages = [(master_doc, "trio", "Trio Documentation", [author], 1)]
229227

230228

231229
# -- Options for Texinfo output -------------------------------------------
@@ -234,7 +232,13 @@ def setup(app):
234232
# (source start file, target name, title, author,
235233
# dir menu entry, description, category)
236234
texinfo_documents = [
237-
(master_doc, 'Trio', 'Trio Documentation',
238-
author, 'Trio', 'One line description of project.',
239-
'Miscellaneous'),
235+
(
236+
master_doc,
237+
"Trio",
238+
"Trio Documentation",
239+
author,
240+
"Trio",
241+
"One line description of project.",
242+
"Miscellaneous",
243+
),
240244
]

docs/source/local_customization.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
from sphinx import addnodes
33
from sphinx.domains.python import PyClasslike
44
from sphinx.ext.autodoc import (
5-
FunctionDocumenter, MethodDocumenter, ClassLevelDocumenter, Options,
5+
FunctionDocumenter,
6+
MethodDocumenter,
7+
ClassLevelDocumenter,
8+
Options,
69
)
710

811
"""
@@ -13,13 +16,15 @@
1316
1417
"""
1518

19+
1620
class Interface(PyClasslike):
1721
def handle_signature(self, sig, signode):
1822
signode += addnodes.desc_name(sig, sig)
1923
return sig, ""
2024

2125
def get_index_text(self, modname, name_cls):
22-
return "{} (interface in {})".format(name_cls[0], modname)
26+
return f"{name_cls[0]} (interface in {modname})"
27+
2328

2429
def setup(app):
2530
app.add_directive_to_domain("py", "interface", Interface)

docs/source/reference-core/channels-backpressure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import trio
55
import math
66

7+
78
async def producer(send_channel):
89
count = 0
910
while True:
@@ -14,17 +15,20 @@ async def producer(send_channel):
1415
print("Sent message:", count)
1516
count += 1
1617

18+
1719
async def consumer(receive_channel):
1820
async for value in receive_channel:
1921
print("Received message:", value)
2022
# Pretend that we have to do some work to handle this message, and it
2123
# takes 1 second
2224
await trio.sleep(1)
2325

26+
2427
async def main():
2528
send_channel, receive_channel = trio.open_memory_channel(math.inf)
2629
async with trio.open_nursery() as nursery:
2730
nursery.start_soon(producer, send_channel)
2831
nursery.start_soon(consumer, receive_channel)
2932

33+
3034
trio.run(main)

docs/source/reference-core/channels-mpmc-broken.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import trio
44
import random
55

6+
67
async def main():
78
async with trio.open_nursery() as nursery:
89
send_channel, receive_channel = trio.open_memory_channel(0)
@@ -13,18 +14,21 @@ async def main():
1314
nursery.start_soon(consumer, "X", receive_channel)
1415
nursery.start_soon(consumer, "Y", receive_channel)
1516

17+
1618
async def producer(name, send_channel):
1719
async with send_channel:
1820
for i in range(3):
1921
await send_channel.send(f"{i} from producer {name}")
2022
# Random sleeps help trigger the problem more reliably
2123
await trio.sleep(random.random())
2224

25+
2326
async def consumer(name, receive_channel):
2427
async with receive_channel:
2528
async for value in receive_channel:
2629
print(f"consumer {name} got value {value!r}")
2730
# Random sleeps help trigger the problem more reliably
2831
await trio.sleep(random.random())
2932

33+
3034
trio.run(main)

docs/source/reference-core/channels-mpmc-fixed.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import trio
22
import random
33

4+
45
async def main():
56
async with trio.open_nursery() as nursery:
67
send_channel, receive_channel = trio.open_memory_channel(0)
@@ -12,18 +13,21 @@ async def main():
1213
nursery.start_soon(consumer, "X", receive_channel.clone())
1314
nursery.start_soon(consumer, "Y", receive_channel.clone())
1415

16+
1517
async def producer(name, send_channel):
1618
async with send_channel:
1719
for i in range(3):
1820
await send_channel.send(f"{i} from producer {name}")
1921
# Random sleeps help trigger the problem more reliably
2022
await trio.sleep(random.random())
2123

24+
2225
async def consumer(name, receive_channel):
2326
async with receive_channel:
2427
async for value in receive_channel:
2528
print(f"consumer {name} got value {value!r}")
2629
# Random sleeps help trigger the problem more reliably
2730
await trio.sleep(random.random())
2831

32+
2933
trio.run(main)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import trio
22

3+
34
async def main():
45
async with trio.open_nursery() as nursery:
56
send_channel, receive_channel = trio.open_memory_channel(0)
67
nursery.start_soon(producer, send_channel)
78
nursery.start_soon(consumer, receive_channel)
89

10+
911
async def producer(send_channel):
1012
async with send_channel:
1113
for i in range(3):
1214
await send_channel.send(f"message {i}")
1315

16+
1417
async def consumer(receive_channel):
1518
async with receive_channel:
1619
async for value in receive_channel:
1720
print(f"got value {value!r}")
1821

22+
1923
trio.run(main)

docs/source/reference-core/channels-simple.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import trio
22

3+
34
async def main():
45
async with trio.open_nursery() as nursery:
56
# Open a channel:
@@ -9,15 +10,18 @@ async def main():
910
nursery.start_soon(producer, send_channel)
1011
nursery.start_soon(consumer, receive_channel)
1112

13+
1214
async def producer(send_channel):
1315
# Producer sends 3 messages
1416
for i in range(3):
1517
# The producer sends using 'await send_channel.send(...)'
1618
await send_channel.send(f"message {i}")
1719

20+
1821
async def consumer(receive_channel):
1922
# The consumer uses an 'async for' loop to receive the values:
2023
async for value in receive_channel:
2124
print(f"got value {value!r}")
2225

26+
2327
trio.run(main)

0 commit comments

Comments
 (0)