Skip to content

Commit 08c972b

Browse files
committed
Merge remote-tracking branch 'origin/master' into drop_3.7
2 parents a2a4fd2 + 6f187fb commit 08c972b

30 files changed

+663
-463
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# sorting all imports with isort
2-
bec33b2a490e4d2a61b0d4d27da8df782ebee4c0
2+
933f77b96f0092e1baab4474a9208fc2e379aa32

docs/source/conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,22 @@
6262
("py:obj", "trio._abc.SendType"),
6363
("py:obj", "trio._abc.T"),
6464
("py:obj", "trio._abc.T_resource"),
65+
("py:class", "types.FrameType"),
6566
]
6667
autodoc_inherit_docstrings = False
6768
default_role = "obj"
6869

70+
# These have incorrect __module__ set in stdlib and give the error
71+
# `py:class reference target not found`
72+
# Some of the nitpick_ignore's above can probably be fixed with this.
73+
# See https://github.com/sphinx-doc/sphinx/issues/8315#issuecomment-751335798
74+
autodoc_type_aliases = {
75+
# aliasing doesn't actually fix the warning for types.FrameType, but displaying
76+
# "types.FrameType" is more helpful than just "frame"
77+
"FrameType": "types.FrameType",
78+
}
79+
80+
6981
# XX hack the RTD theme until
7082
# https://github.com/rtfd/sphinx_rtd_theme/pull/382
7183
# is shipped (should be in the release after 0.2.4)

docs/source/history.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ Release history
55

66
.. towncrier release notes start
77
8+
Trio 0.22.2 (2023-07-13)
9+
------------------------
10+
11+
Bugfixes
12+
~~~~~~~~
13+
14+
- Fix ``PermissionError`` when importing `trio` due to trying to access ``pthread``. (`#2688 <https://github.com/python-trio/trio/issues/2688>`__)
15+
16+
817
Trio 0.22.1 (2023-07-02)
918
------------------------
1019

docs/source/reference-core.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ Broadcasting an event with :class:`Event`
10921092
.. autoclass:: Event
10931093
:members:
10941094

1095+
.. autoclass:: EventStatistics
1096+
:members:
10951097

10961098
.. _channels:
10971099

@@ -1452,6 +1454,16 @@ don't have any special access to Trio's internals.)
14521454
.. autoclass:: Condition
14531455
:members:
14541456

1457+
These primitives return statistics objects that can be inspected.
1458+
1459+
.. autoclass:: CapacityLimiterStatistics
1460+
:members:
1461+
1462+
.. autoclass:: LockStatistics
1463+
:members:
1464+
1465+
.. autoclass:: ConditionStatistics
1466+
:members:
14551467

14561468
.. _async-generators:
14571469

docs/source/reference-lowlevel.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ Wait queue abstraction
378378
:members:
379379
:undoc-members:
380380

381+
.. autoclass:: ParkingLotStatistics
382+
:members:
381383

382384
Low-level checkpoint functions
383385
------------------------------

mypy.ini

Lines changed: 0 additions & 25 deletions
This file was deleted.

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@ combine_as_imports = true
1919
profile = "black"
2020
skip_gitignore = true
2121

22+
[tool.mypy]
23+
python_version = "3.8"
24+
25+
# Be flexible about dependencies that don't have stubs yet (like pytest)
26+
ignore_missing_imports = true
27+
28+
# Be strict about use of Mypy
29+
warn_unused_ignores = true
30+
warn_unused_configs = true
31+
warn_redundant_casts = true
32+
warn_return_any = true
33+
34+
# Avoid subtle backsliding
35+
#disallow_any_decorated = true
36+
#disallow_incomplete_defs = true
37+
#disallow_subclassing_any = true
38+
39+
# Enable gradually / for new modules
40+
check_untyped_defs = false
41+
disallow_untyped_calls = false
42+
disallow_untyped_defs = false
43+
44+
# DO NOT use `ignore_errors`; it doesn't apply
45+
# downstream and users have to deal with them.
46+
2247
[tool.pytest.ini_options]
2348
addopts = ["--strict-markers", "--strict-config"]
2449
faulthandler_timeout = 60

trio/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@
7878
from ._subprocess import Process as Process, run_process as run_process
7979
from ._sync import (
8080
CapacityLimiter as CapacityLimiter,
81+
CapacityLimiterStatistics as CapacityLimiterStatistics,
8182
Condition as Condition,
83+
ConditionStatistics as ConditionStatistics,
8284
Event as Event,
85+
EventStatistics as EventStatistics,
8386
Lock as Lock,
87+
LockStatistics as LockStatistics,
8488
Semaphore as Semaphore,
8589
StrictFIFOLock as StrictFIFOLock,
8690
)

trio/_abc.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
from __future__ import annotations
2+
13
from abc import ABCMeta, abstractmethod
2-
from typing import Generic, TypeVar
4+
from typing import TYPE_CHECKING, Generic, TypeVar
35

46
import trio
57

8+
if TYPE_CHECKING:
9+
from types import TracebackType
10+
11+
from typing_extensions import Self
12+
613

714
# We use ABCMeta instead of ABC, plus set __slots__=(), so as not to force a
815
# __dict__ onto subclasses.
@@ -12,15 +19,15 @@ class Clock(metaclass=ABCMeta):
1219
__slots__ = ()
1320

1421
@abstractmethod
15-
def start_clock(self):
22+
def start_clock(self) -> None:
1623
"""Do any setup this clock might need.
1724
1825
Called at the beginning of the run.
1926
2027
"""
2128

2229
@abstractmethod
23-
def current_time(self):
30+
def current_time(self) -> float:
2431
"""Return the current time, according to this clock.
2532
2633
This is used to implement functions like :func:`trio.current_time` and
@@ -32,7 +39,7 @@ def current_time(self):
3239
"""
3340

3441
@abstractmethod
35-
def deadline_to_sleep_time(self, deadline):
42+
def deadline_to_sleep_time(self, deadline: float) -> float:
3643
"""Compute the real time until the given deadline.
3744
3845
This is called before we enter a system-specific wait function like
@@ -225,7 +232,7 @@ class AsyncResource(metaclass=ABCMeta):
225232
__slots__ = ()
226233

227234
@abstractmethod
228-
async def aclose(self):
235+
async def aclose(self) -> None:
229236
"""Close this resource, possibly blocking.
230237
231238
IMPORTANT: This method may block in order to perform a "graceful"
@@ -253,10 +260,15 @@ async def aclose(self):
253260
254261
"""
255262

256-
async def __aenter__(self):
263+
async def __aenter__(self) -> Self:
257264
return self
258265

259-
async def __aexit__(self, *args):
266+
async def __aexit__(
267+
self,
268+
exc_type: type[BaseException] | None,
269+
exc_value: BaseException | None,
270+
traceback: TracebackType | None,
271+
) -> None:
260272
await self.aclose()
261273

262274

@@ -279,7 +291,7 @@ class SendStream(AsyncResource):
279291
__slots__ = ()
280292

281293
@abstractmethod
282-
async def send_all(self, data):
294+
async def send_all(self, data: bytes | bytearray | memoryview) -> None:
283295
"""Sends the given data through the stream, blocking if necessary.
284296
285297
Args:
@@ -305,7 +317,7 @@ async def send_all(self, data):
305317
"""
306318

307319
@abstractmethod
308-
async def wait_send_all_might_not_block(self):
320+
async def wait_send_all_might_not_block(self) -> None:
309321
"""Block until it's possible that :meth:`send_all` might not block.
310322
311323
This method may return early: it's possible that after it returns,
@@ -385,7 +397,7 @@ class ReceiveStream(AsyncResource):
385397
__slots__ = ()
386398

387399
@abstractmethod
388-
async def receive_some(self, max_bytes=None):
400+
async def receive_some(self, max_bytes: int | None = None) -> bytes | bytearray:
389401
"""Wait until there is data available on this stream, and then return
390402
some of it.
391403
@@ -413,10 +425,10 @@ async def receive_some(self, max_bytes=None):
413425
414426
"""
415427

416-
def __aiter__(self):
428+
def __aiter__(self) -> Self:
417429
return self
418430

419-
async def __anext__(self):
431+
async def __anext__(self) -> bytes | bytearray:
420432
data = await self.receive_some()
421433
if not data:
422434
raise StopAsyncIteration
@@ -446,7 +458,7 @@ class HalfCloseableStream(Stream):
446458
__slots__ = ()
447459

448460
@abstractmethod
449-
async def send_eof(self):
461+
async def send_eof(self) -> None:
450462
"""Send an end-of-file indication on this stream, if possible.
451463
452464
The difference between :meth:`send_eof` and
@@ -632,7 +644,7 @@ async def receive(self) -> ReceiveType:
632644
633645
"""
634646

635-
def __aiter__(self):
647+
def __aiter__(self) -> Self:
636648
return self
637649

638650
async def __anext__(self) -> ReceiveType:

trio/_channel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ def __enter__(self: SelfT) -> SelfT:
243243
def __exit__(
244244
self,
245245
exc_type: type[BaseException] | None,
246-
exc_val: BaseException | None,
247-
exc_tb: TracebackType | None,
246+
exc_value: BaseException | None,
247+
traceback: TracebackType | None,
248248
) -> None:
249249
self.close()
250250

@@ -389,8 +389,8 @@ def __enter__(self: SelfT) -> SelfT:
389389
def __exit__(
390390
self,
391391
exc_type: type[BaseException] | None,
392-
exc_val: BaseException | None,
393-
exc_tb: TracebackType | None,
392+
exc_value: BaseException | None,
393+
traceback: TracebackType | None,
394394
) -> None:
395395
self.close()
396396

0 commit comments

Comments
 (0)