Skip to content

Commit 354708e

Browse files
github-actions[bot]A5rockspre-commit-ci[bot]
authored
Bump dependencies from commit 009bc2 (#3559)
* Dependency updates * Messy fixes for mypy upgrade * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Try appeasing Sphinx * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Maybe I should have done this locally * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: A5rocks <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 009bc2d commit 354708e

13 files changed

Lines changed: 160 additions & 115 deletions

‎.pre-commit-config.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
hooks:
2525
- id: black
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.17.1
27+
rev: v0.17.2
2828
hooks:
2929
- id: ruff-check
3030
types: [file]
@@ -69,7 +69,7 @@ repos:
6969
additional_dependencies: ["pyyaml"]
7070
files: ^(test-requirements\.txt)|(\.pre-commit-config\.yaml)$
7171
- repo: https://github.com/astral-sh/uv-pre-commit
72-
rev: 0.13.1
72+
rev: 0.13.5
7373
hooks:
7474
# Compile requirements
7575
- id: pip-compile

‎docs-requirements.txt‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ babel==2.18.0
1010
# via sphinx
1111
beautifulsoup4==4.15.0
1212
# via sphinx-codeautolink
13-
certifi==2026.7.22
13+
certifi==2026.10.23
1414
# via requests
1515
cffi==2.1.1 ; os_name == 'nt' or platform_python_implementation != 'PyPy'
1616
# via
@@ -43,13 +43,13 @@ jinja2==3.1.6
4343
# -r docs-requirements.in
4444
# sphinx
4545
# towncrier
46-
markupsafe==3.0.3
46+
markupsafe==3.0.4
4747
# via jinja2
4848
outcome==1.3.0.post0
4949
# via -r docs-requirements.in
5050
packaging==26.3
5151
# via sphinx
52-
pycparser==3.0 ; (implementation_name != 'PyPy' and os_name == 'nt') or (implementation_name != 'PyPy' and platform_python_implementation != 'PyPy')
52+
pycparser==3.12 ; (implementation_name != 'PyPy' and os_name == 'nt') or (implementation_name != 'PyPy' and platform_python_implementation != 'PyPy')
5353
# via cffi
5454
pygments==2.21.0
5555
# via sphinx
@@ -65,7 +65,9 @@ snowballstemmer==3.1.1
6565
# via sphinx
6666
sortedcontainers==2.4.0
6767
# via -r docs-requirements.in
68-
soupsieve==2.10
68+
soupsieve==2.10 ; python_full_version < '3.11.5'
69+
# via beautifulsoup4
70+
soupsieve==3.0.4 ; python_full_version >= '3.11.5'
6971
# via beautifulsoup4
7072
sphinx==9.0.4 ; python_full_version < '3.12'
7173
# via
@@ -74,7 +76,14 @@ sphinx==9.0.4 ; python_full_version < '3.12'
7476
# sphinx-rtd-theme
7577
# sphinxcontrib-jquery
7678
# sphinxcontrib-trio
77-
sphinx==9.1.0 ; python_full_version >= '3.12'
79+
sphinx==9.1.1 ; python_full_version == '3.12.*'
80+
# via
81+
# -r docs-requirements.in
82+
# sphinx-codeautolink
83+
# sphinx-rtd-theme
84+
# sphinxcontrib-jquery
85+
# sphinxcontrib-trio
86+
sphinx==9.2.0 ; python_full_version >= '3.13'
7887
# via
7988
# -r docs-requirements.in
8089
# sphinx-codeautolink
@@ -95,7 +104,7 @@ sphinxcontrib-jquery==4.1
95104
# via
96105
# -r docs-requirements.in
97106
# sphinx-rtd-theme
98-
sphinxcontrib-jsmath==1.0.1
107+
sphinxcontrib-jsmath==2.0.0
99108
# via sphinx
100109
sphinxcontrib-qthelp==2.0.0
101110
# via sphinx

‎src/trio/_abc.py‎

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

33
import socket
44
from abc import ABC, abstractmethod
5-
from typing import TYPE_CHECKING, Generic, TypeVar
5+
from typing import TYPE_CHECKING, Generic, Literal, TypeVar
66

77
import trio
88

@@ -173,12 +173,20 @@ async def getaddrinfo(
173173
proto: int = 0,
174174
flags: int = 0,
175175
) -> list[
176+
# copied from _GetAddrInfoEntry
176177
tuple[
177-
socket.AddressFamily,
178+
Literal[socket.AddressFamily.AF_INET],
178179
socket.SocketKind,
179180
int,
180181
str,
181-
tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes],
182+
tuple[str, int],
183+
]
184+
| tuple[
185+
Literal[socket.AddressFamily.AF_INET6],
186+
socket.SocketKind,
187+
int,
188+
str,
189+
tuple[str, int, int, int] | tuple[int, bytes],
182190
]
183191
]:
184192
"""A custom implementation of :func:`~trio.socket.getaddrinfo`.

‎src/trio/_dtls.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def __init__(
841841
self.endpoint = endpoint
842842
self.peer_address = peer_address
843843
self._packets_dropped_in_trio = 0
844-
self._client_hello = None
844+
self._client_hello: tuple[bytes, bytes] | None = None
845845
self._did_handshake = False
846846
self._ssl = SSL.Connection(ctx)
847847
self._handshake_mtu = 0

‎src/trio/_highlevel_open_tcp_stream.py‎

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

33
import sys
44
from contextlib import contextmanager, suppress
5-
from typing import TYPE_CHECKING, Any
5+
from typing import TYPE_CHECKING
66

77
import trio
88
from trio.socket import SOCK_STREAM, SocketType, getaddrinfo, socket
@@ -11,7 +11,7 @@
1111
from collections.abc import Generator, MutableSequence
1212
from socket import AddressFamily, SocketKind
1313

14-
from trio._socket import AddressFormat
14+
from trio._socket import AddressFormat, _GetAddrInfoEntry
1515

1616
if sys.version_info < (3, 11):
1717
from exceptiongroup import BaseExceptionGroup, ExceptionGroup
@@ -134,8 +134,8 @@ def close_all() -> Generator[set[SocketType], None, None]:
134134
raise BaseExceptionGroup("", errs)
135135

136136

137-
def reorder_for_rfc_6555_section_5_4( # type: ignore[explicit-any]
138-
targets: MutableSequence[tuple[AddressFamily, SocketKind, int, str, Any]],
137+
def reorder_for_rfc_6555_section_5_4(
138+
targets: MutableSequence[_GetAddrInfoEntry],
139139
) -> None:
140140
# RFC 6555 section 5.4 says that if getaddrinfo returns multiple address
141141
# families (e.g. IPv4 and IPv6), then you should make sure that your first

‎src/trio/_socket.py‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
TYPE_CHECKING,
1111
Any,
1212
Concatenate,
13+
Literal,
1314
SupportsIndex,
1415
TypeAlias,
1516
TypeVar,
@@ -49,6 +50,25 @@
4950
# but instead we simply do:
5051
AddressFormat: TypeAlias = Any # type: ignore[explicit-any]
5152

53+
# typeshed defines _GetAddrInfoResult but we would rather manipulate the inner
54+
# entry type... as well as use a type defined at runtime!
55+
_GetAddrInfoEntry: TypeAlias = ( # noqa: PYI047
56+
tuple[
57+
Literal[AddressFamily.AF_INET],
58+
SocketKind,
59+
int,
60+
str,
61+
tuple[str, int],
62+
]
63+
| tuple[
64+
Literal[AddressFamily.AF_INET6],
65+
SocketKind,
66+
int,
67+
str,
68+
tuple[str, int, int, int] | tuple[int, bytes],
69+
]
70+
)
71+
5272

5373
# Usage:
5474
#
@@ -180,12 +200,20 @@ async def getaddrinfo(
180200
proto: int = 0,
181201
flags: int = 0,
182202
) -> list[
203+
# copied from _GetAddrInfoEntry
183204
tuple[
184-
AddressFamily,
205+
Literal[AddressFamily.AF_INET],
206+
SocketKind,
207+
int,
208+
str,
209+
tuple[str, int],
210+
]
211+
| tuple[
212+
Literal[AddressFamily.AF_INET6],
185213
SocketKind,
186214
int,
187215
str,
188-
tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes],
216+
tuple[str, int, int, int] | tuple[int, bytes],
189217
]
190218
]:
191219
"""Look up a numeric address given a name.

‎src/trio/_tests/test_exports.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
try: # If installed, check both versions of this class.
3434
from typing_extensions import Protocol as Protocol_ext
3535
except ImportError: # pragma: no cover
36-
Protocol_ext = Protocol
36+
Protocol_ext = Protocol # type: ignore[assignment]
3737

3838

3939
def _ensure_mypy_cache_updated() -> None:

‎src/trio/_tests/test_highlevel_open_tcp_listeners.py‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import socket as stdlib_socket
55
import sys
66
from socket import AddressFamily, SocketKind
7-
from typing import TYPE_CHECKING, cast, overload
7+
from typing import TYPE_CHECKING, Literal, cast, overload
88

99
import attrs
1010
import pytest
@@ -30,7 +30,7 @@
3030

3131
from typing_extensions import Buffer
3232

33-
from trio._socket import AddressFormat
33+
from trio._socket import AddressFormat, _GetAddrInfoEntry
3434

3535

3636
async def test_open_tcp_listeners_basic() -> None:
@@ -242,7 +242,9 @@ def socket(
242242

243243
@attrs.define(slots=False)
244244
class FakeHostnameResolver(HostnameResolver):
245-
family_addr_pairs: Sequence[tuple[AddressFamily, str]]
245+
family_addr_pairs: Sequence[
246+
tuple[Literal[AddressFamily.AF_INET, AddressFamily.AF_INET6], str]
247+
]
246248

247249
async def getaddrinfo(
248250
self,
@@ -252,18 +254,14 @@ async def getaddrinfo(
252254
type: int = 0,
253255
proto: int = 0,
254256
flags: int = 0,
255-
) -> list[
256-
tuple[
257-
AddressFamily,
258-
SocketKind,
259-
int,
260-
str,
261-
tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes],
262-
]
263-
]:
257+
) -> list[_GetAddrInfoEntry]:
264258
assert isinstance(port, int)
265259
return [
266-
(family, tsocket.SOCK_STREAM, 0, "", (addr, port))
260+
(
261+
(family, tsocket.SOCK_STREAM, 0, "", (addr, port))
262+
if family is AddressFamily.AF_INET
263+
else (family, tsocket.SOCK_STREAM, 0, "", (addr, port, 0, 0))
264+
)
267265
for family, addr in self.family_addr_pairs
268266
]
269267

@@ -333,7 +331,7 @@ async def handler(stream: SendStream) -> None:
333331
[{tsocket.AF_INET}, {tsocket.AF_INET6}, {tsocket.AF_INET, tsocket.AF_INET6}],
334332
)
335333
async def test_open_tcp_listeners_some_address_families_unavailable(
336-
try_families: set[AddressFamily],
334+
try_families: set[Literal[AddressFamily.AF_INET, AddressFamily.AF_INET6]],
337335
fail_families: set[AddressFamily],
338336
) -> None:
339337
fsf = FakeSocketFactory(
@@ -360,6 +358,10 @@ async def test_open_tcp_listeners_some_address_families_unavailable(
360358
else:
361359
listeners = await open_tcp_listeners(80)
362360
for listener in listeners:
361+
assert (
362+
listener.socket.family is AddressFamily.AF_INET
363+
or listener.socket.family is AddressFamily.AF_INET6
364+
)
363365
should_succeed.remove(listener.socket.family)
364366
assert not should_succeed
365367

‎src/trio/_tests/test_highlevel_open_tcp_stream.py‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import socket
44
import sys
55
from socket import AddressFamily, SocketKind
6-
from typing import TYPE_CHECKING
6+
from typing import TYPE_CHECKING, Literal
77

88
import attrs
99
import pytest
@@ -20,6 +20,7 @@
2020
if TYPE_CHECKING:
2121
from collections.abc import Sequence
2222

23+
from trio._socket import _GetAddrInfoEntry
2324
from trio.testing import MockClock
2425

2526
if sys.version_info < (3, 11):
@@ -60,7 +61,7 @@ def close(self) -> None:
6061
def test_reorder_for_rfc_6555_section_5_4() -> None:
6162
def fake4(
6263
i: int,
63-
) -> tuple[socket.AddressFamily, socket.SocketKind, int, str, tuple[str, int]]:
64+
) -> _GetAddrInfoEntry:
6465
return (
6566
AF_INET,
6667
SOCK_STREAM,
@@ -71,8 +72,14 @@ def fake4(
7172

7273
def fake6(
7374
i: int,
74-
) -> tuple[socket.AddressFamily, socket.SocketKind, int, str, tuple[str, int]]:
75-
return (AF_INET6, SOCK_STREAM, IPPROTO_TCP, "", (f"::{i}", 80))
75+
) -> tuple[
76+
Literal[AddressFamily.AF_INET6],
77+
SocketKind,
78+
int,
79+
str,
80+
tuple[str, int, int, int] | tuple[int, bytes],
81+
]:
82+
return (AF_INET6, SOCK_STREAM, IPPROTO_TCP, "", (f"::{i}", 80, 0, 0))
7683

7784
for fake in fake4, fake6:
7885
# No effect on homogeneous lists
@@ -281,21 +288,17 @@ def socket(
281288
self.socket_count += 1
282289
return FakeSocket(self, family, type_, proto)
283290

284-
def _ip_to_gai_entry(self, ip: str) -> tuple[
285-
AddressFamily,
286-
SocketKind,
287-
int,
288-
str,
289-
tuple[str, int, int, int] | tuple[str, int] | tuple[int, bytes],
290-
]:
291-
sockaddr: tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]
291+
def _ip_to_gai_entry(self, ip: str) -> _GetAddrInfoEntry:
292292
if ":" in ip:
293-
family = trio.socket.AF_INET6
294-
sockaddr = (ip, self.port, 0, 0)
293+
return (
294+
trio.socket.AF_INET6,
295+
SOCK_STREAM,
296+
IPPROTO_TCP,
297+
"",
298+
(ip, self.port, 0, 0),
299+
)
295300
else:
296-
family = trio.socket.AF_INET
297-
sockaddr = (ip, self.port)
298-
return (family, SOCK_STREAM, IPPROTO_TCP, "", sockaddr)
301+
return (trio.socket.AF_INET, SOCK_STREAM, IPPROTO_TCP, "", (ip, self.port))
299302

300303
async def getaddrinfo(
301304
self,
@@ -305,15 +308,7 @@ async def getaddrinfo(
305308
type: int = -1,
306309
proto: int = -1,
307310
flags: int = -1,
308-
) -> list[
309-
tuple[
310-
AddressFamily,
311-
SocketKind,
312-
int,
313-
str,
314-
tuple[str, int, int, int] | tuple[str, int] | tuple[int, bytes],
315-
]
316-
]:
311+
) -> list[_GetAddrInfoEntry]:
317312
assert host == b"test.example.com"
318313
assert port == self.port
319314
assert family == trio.socket.AF_UNSPEC

0 commit comments

Comments
 (0)