Skip to content

Commit 7b8881a

Browse files
committed
Merge remote-tracking branch 'origin/main' into remove_notes_to_self
2 parents dfcb690 + c4c8ce4 commit 7b8881a

29 files changed

+319
-227
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ name: CI
33
on:
44
push:
55
branches-ignore:
6-
- "dependabot/**"
6+
# these branches always have another event associated
7+
- gh-readonly-queue/** # GitHub's merge queue uses `merge_group`
8+
- autodeps/** # autodeps always makes a PR
9+
- pre-commit-ci-update-config # pre-commit.ci's updates always have a PR
710
pull_request:
11+
merge_group:
812

913
concurrency:
1014
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
@@ -118,16 +122,10 @@ jobs:
118122
uses: actions/checkout@v4
119123
- name: Setup python
120124
uses: actions/setup-python@v5
121-
if: "!endsWith(matrix.python, '-dev')"
122125
with:
123126
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
124127
cache: pip
125128
cache-dependency-path: test-requirements.txt
126-
- name: Setup python (dev)
127-
uses: deadsnakes/action@v2.0.2
128-
if: endsWith(matrix.python, '-dev')
129-
with:
130-
python-version: '${{ matrix.python }}'
131129
- name: Run tests
132130
run: ./ci.sh
133131
env:
@@ -189,7 +187,8 @@ jobs:
189187
# can't use setup-python because that python doesn't seem to work;
190188
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
191189
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
192-
run: apk update && apk add python3-dev bash nodejs
190+
# `perl` for a platform independent `sed -i` alternative
191+
run: apk update && apk add python3-dev bash nodejs perl
193192
- name: Enter virtual environment
194193
run: python -m venv .venv
195194
- name: Run tests

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
hooks:
2323
- id: black
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.8.0
25+
rev: v0.8.2
2626
hooks:
2727
- id: ruff
2828
types: [file]

ci.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,29 @@ else
116116
echo "::group::Setup for tests"
117117

118118
# We run the tests from inside an empty directory, to make sure Python
119-
# doesn't pick up any .py files from our working dir. Might have been
120-
# pre-created by some of the code above.
119+
# doesn't pick up any .py files from our working dir. Might have already
120+
# been created by a previous run.
121121
mkdir empty || true
122122
cd empty
123123

124124
INSTALLDIR=$(python -c "import os, trio; print(os.path.dirname(trio.__file__))")
125-
cp ../pyproject.toml "$INSTALLDIR"
125+
cp ../pyproject.toml "$INSTALLDIR" # TODO: remove this
126126

127127
# get mypy tests a nice cache
128128
MYPYPATH=".." mypy --config-file= --cache-dir=./.mypy_cache -c "import trio" >/dev/null 2>/dev/null || true
129129

130130
# support subprocess spawning with coverage.py
131131
echo "import coverage; coverage.process_startup()" | tee -a "$INSTALLDIR/../sitecustomize.py"
132132

133+
perl -i -pe 's/-p trio\._tests\.pytest_plugin//' "$INSTALLDIR/pyproject.toml"
134+
133135
echo "::endgroup::"
134136
echo "::group:: Run Tests"
135-
if COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml coverage run --rcfile=../pyproject.toml -m pytest -ra --junitxml=../test-results.xml --run-slow "${INSTALLDIR}" --verbose --durations=10 $flags; then
137+
if PYTHONPATH=../tests COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml \
138+
coverage run --rcfile=../pyproject.toml -m \
139+
pytest -ra --junitxml=../test-results.xml \
140+
-p _trio_check_attrs_aliases --verbose --durations=10 \
141+
-p trio._tests.pytest_plugin --run-slow $flags "${INSTALLDIR}"; then
136142
PASSED=true
137143
else
138144
PASSED=false

docs-requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows'
2424
# via
2525
# click
2626
# sphinx
27-
cryptography==43.0.3
27+
cryptography==44.0.0
2828
# via pyopenssl
2929
docutils==0.21.2
3030
# via
@@ -49,13 +49,13 @@ markupsafe==3.0.2
4949
# via jinja2
5050
outcome==1.3.0.post0
5151
# via -r docs-requirements.in
52-
packaging==24.1
52+
packaging==24.2
5353
# via sphinx
5454
pycparser==2.22 ; platform_python_implementation != 'PyPy' or os_name == 'nt'
5555
# via cffi
5656
pygments==2.18.0
5757
# via sphinx
58-
pyopenssl==24.2.1
58+
pyopenssl==24.3.0
5959
# via -r docs-requirements.in
6060
requests==2.32.3
6161
# via sphinx
@@ -77,9 +77,9 @@ sphinx==8.1.3
7777
# sphinxcontrib-trio
7878
sphinx-codeautolink==0.15.2
7979
# via -r docs-requirements.in
80-
sphinx-hoverxref==1.4.1
80+
sphinx-hoverxref==1.4.2
8181
# via -r docs-requirements.in
82-
sphinx-rtd-theme==3.0.1
82+
sphinx-rtd-theme==3.0.2
8383
# via -r docs-requirements.in
8484
sphinxcontrib-applehelp==2.0.0
8585
# via sphinx

docs/source/conf.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import glob
2323
import os
2424
import sys
25-
import types
2625
from pathlib import Path
2726
from typing import TYPE_CHECKING, cast
2827

@@ -152,16 +151,6 @@ def autodoc_process_signature(
152151
return_annotation: str,
153152
) -> tuple[str, str]:
154153
"""Modify found signatures to fix various issues."""
155-
if name == "trio.testing._raises_group._ExceptionInfo.type":
156-
# This has the type "type[E]", which gets resolved into the property itself.
157-
# That means Sphinx can't resolve it. Fix the issue by overwriting with a fully-qualified
158-
# name.
159-
assert isinstance(obj, property), obj
160-
assert isinstance(obj.fget, types.FunctionType), obj.fget
161-
assert (
162-
obj.fget.__annotations__["return"] == "type[MatchE]"
163-
), obj.fget.__annotations__
164-
obj.fget.__annotations__["return"] = "type[~trio.testing._raises_group.MatchE]"
165154
if signature is not None:
166155
signature = signature.replace("~_contextvars.Context", "~contextvars.Context")
167156
if name == "trio.lowlevel.RunVar": # Typevar is not useful here.
@@ -170,16 +159,6 @@ def autodoc_process_signature(
170159
# Strip the type from the union, make it look like = ...
171160
signature = signature.replace(" | type[trio._core._local._NoValue]", "")
172161
signature = signature.replace("<class 'trio._core._local._NoValue'>", "...")
173-
if name in ("trio.testing.RaisesGroup", "trio.testing.Matcher") and (
174-
"+E" in signature or "+MatchE" in signature
175-
):
176-
# This typevar being covariant isn't handled correctly in some cases, strip the +
177-
# and insert the fully-qualified name.
178-
signature = signature.replace("+E", "~trio.testing._raises_group.E")
179-
signature = signature.replace(
180-
"+MatchE",
181-
"~trio.testing._raises_group.MatchE",
182-
)
183162
if "DTLS" in name:
184163
signature = signature.replace("SSL.Context", "OpenSSL.SSL.Context")
185164
# Don't specify PathLike[str] | PathLike[bytes], this is just for humans.

newsfragments/3114.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure that Pyright recognizes our underscore prefixed attributes for attrs classes.

newsfragments/3141.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix `trio.testing.RaisesGroup`'s typing.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ reportUnnecessaryTypeIgnoreComment = true
201201
typeCheckingMode = "strict"
202202

203203
[tool.pytest.ini_options]
204-
addopts = ["--strict-markers", "--strict-config", "-p trio._tests.pytest_plugin"]
204+
addopts = ["--strict-markers", "--strict-config", "-p trio._tests.pytest_plugin", "--import-mode=importlib"]
205205
faulthandler_timeout = 60
206206
filterwarnings = [
207207
"error",

src/trio/_core/_concat_tb.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import annotations
22

3-
from types import TracebackType
43
from typing import TYPE_CHECKING, ClassVar, cast
54

5+
if TYPE_CHECKING:
6+
from types import TracebackType
7+
68
################################################################
79
# concat_tb
810
################################################################
@@ -107,7 +109,7 @@ def controller( # type: ignore[no-any-unimported]
107109
return operation.delegate() # type: ignore[no-any-return]
108110

109111
return cast(
110-
TracebackType,
112+
"TracebackType",
111113
tputil.make_proxy(controller, type(base_tb), base_tb),
112114
) # Returns proxy to traceback
113115

src/trio/_core/_io_windows.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def _refresh_afd(self, base_handle: Handle) -> None:
701701

702702
lpOverlapped = ffi.new("LPOVERLAPPED")
703703

704-
poll_info = cast(_AFDPollInfo, ffi.new("AFD_POLL_INFO *"))
704+
poll_info = cast("_AFDPollInfo", ffi.new("AFD_POLL_INFO *"))
705705
poll_info.Timeout = 2**63 - 1 # INT64_MAX
706706
poll_info.NumberOfHandles = 1
707707
poll_info.Exclusive = 0
@@ -714,9 +714,9 @@ def _refresh_afd(self, base_handle: Handle) -> None:
714714
kernel32.DeviceIoControl(
715715
afd_group.handle,
716716
IoControlCodes.IOCTL_AFD_POLL,
717-
cast(CType, poll_info),
717+
cast("CType", poll_info),
718718
ffi.sizeof("AFD_POLL_INFO"),
719-
cast(CType, poll_info),
719+
cast("CType", poll_info),
720720
ffi.sizeof("AFD_POLL_INFO"),
721721
ffi.NULL,
722722
lpOverlapped,
@@ -938,13 +938,13 @@ async def _perform_overlapped(
938938
# operation will not be cancellable, depending on how Windows is
939939
# feeling today. So we need to check for cancellation manually.
940940
await _core.checkpoint_if_cancelled()
941-
lpOverlapped = cast(_Overlapped, ffi.new("LPOVERLAPPED"))
941+
lpOverlapped = cast("_Overlapped", ffi.new("LPOVERLAPPED"))
942942
try:
943943
submit_fn(lpOverlapped)
944944
except OSError as exc:
945945
if exc.winerror != ErrorCodes.ERROR_IO_PENDING:
946946
raise
947-
await self.wait_overlapped(handle, cast(CData, lpOverlapped))
947+
await self.wait_overlapped(handle, cast("CData", lpOverlapped))
948948
return lpOverlapped
949949

950950
@_public

0 commit comments

Comments
 (0)