Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ jobs:
- build

runs-on: ubuntu-latest
container: alpine
container: alpine:3
steps:
- name: Install necessary packages
# can't use setup-python because that python doesn't seem to work;
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ repos:
- id: sort-simple-yaml
files: .pre-commit-config.yaml
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
rev: 26.5.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
rev: v0.15.13
hooks:
- id: ruff-check
types: [file]
Expand All @@ -38,15 +38,15 @@ repos:
# tomli needed on 3.10. tomllib is available in stdlib on 3.11+
- tomli
- repo: https://github.com/adhtruong/mirrors-typos
rev: v1.46.1
rev: v1.46.2
hooks:
- id: typos
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.2
hooks:
- id: sphinx-lint
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.24.1
rev: v1.25.2
hooks:
- id: zizmor
- repo: local
Expand All @@ -73,7 +73,7 @@ repos:
additional_dependencies: ["pyyaml"]
files: ^(test-requirements\.txt)|(\.pre-commit-config\.yaml)$
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.13
rev: 0.11.14
hooks:
# Compile requirements
- id: pip-compile
Expand Down
12 changes: 6 additions & 6 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ cffi==2.0.0 ; os_name == 'nt' or platform_python_implementation != 'PyPy'
# cryptography
charset-normalizer==3.4.7
# via requests
click==8.3.3
click==8.4.0
# via towncrier
colorama==0.4.6 ; sys_platform == 'win32'
# via
# click
# sphinx
cryptography==47.0.0
cryptography==48.0.0
# via pyopenssl
docutils==0.22.4
# via
# sphinx
# sphinx-rtd-theme
exceptiongroup==1.3.1
# via -r docs-requirements.in
idna==3.13
idna==3.15
# via
# -r docs-requirements.in
# requests
Expand All @@ -55,9 +55,9 @@ pycparser==3.0 ; (implementation_name != 'PyPy' and os_name == 'nt') or (impleme
# via cffi
pygments==2.20.0
# via sphinx
pyopenssl==26.1.0
pyopenssl==26.2.0
# via -r docs-requirements.in
requests==2.33.1
requests==2.34.2
# via sphinx
roman-numerals==4.1.0
# via sphinx
Expand Down Expand Up @@ -112,5 +112,5 @@ typing-extensions==4.15.0
# beautifulsoup4
# exceptiongroup
# pyopenssl
urllib3==2.6.3
urllib3==2.7.0
# via requests
2 changes: 1 addition & 1 deletion src/trio/_highlevel_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def send_eof(self) -> None:
return await stream.aclose()

# we intentionally accept more types from the caller than we support returning
async def receive_some(self, max_bytes: int | None = None) -> bytes:
async def receive_some(self, max_bytes: int | None = None) -> bytes | bytearray:
"""Calls ``self.receive_stream.receive_some``."""
return await self.receive_stream.receive_some(max_bytes)

Expand Down
8 changes: 5 additions & 3 deletions src/trio/_tests/test_dtls.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ async def test_server_socket_doesnt_crash_on_garbage(

async with dtls_echo_server(server_ctx=server_ctx) as (_, address):
with trio.socket.socket(type=trio.socket.SOCK_DGRAM) as sock:
for bad_packet in [
bad_packets: list[bytes | bytearray | memoryview[int]] = [
b"",
b"xyz",
client_hello_extended,
Expand All @@ -497,7 +497,9 @@ async def test_server_socket_doesnt_crash_on_garbage(
client_hello_trailing_data_in_record,
handshake_empty,
client_hello_truncated_in_cookie,
]:
]

for bad_packet in bad_packets:
await sock.sendto(bad_packet, address)
await trio.sleep(1)

Expand Down Expand Up @@ -532,7 +534,7 @@ def route_packet(packet: UDPPacket) -> None:
offset = len(payload) - 1
cscope.cancel()
payload[offset] ^= 0x01
packet = attrs.evolve(packet, payload=payload)
packet = attrs.evolve(packet, payload=bytes(payload))

fn.deliver_packet(packet)

Expand Down
42 changes: 19 additions & 23 deletions src/trio/_tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,18 +417,7 @@ def lookup_symbol(symbol: str) -> dict[str, Any]: # type: ignore[misc, explicit
# using .remove() instead of .delete() to get an error in case they start not
# being missing

if (
tool == "jedi"
and BaseException in class_.__mro__
and sys.version_info >= (3, 11)
):
missing.remove("add_note")

if (
tool == "mypy"
and BaseException in class_.__mro__
and sys.version_info >= (3, 11)
):
if BaseException in class_.__mro__ and sys.version_info >= (3, 11):
extra.remove("__notes__")

if tool == "mypy" and attrs.has(class_):
Expand All @@ -443,8 +432,7 @@ def lookup_symbol(symbol: str) -> dict[str, Any]: # type: ignore[misc, explicit

# dir does not see `__signature__` on enums until 3.14
if (
tool == "mypy"
and enum.Enum in class_.__mro__
enum.Enum in class_.__mro__
and sys.version_info >= (3, 12)
and sys.version_info < (3, 14)
):
Expand Down Expand Up @@ -508,16 +496,8 @@ def lookup_symbol(symbol: str) -> dict[str, Any]: # type: ignore[misc, explicit
if tool == "jedi" and sys.platform == "win32":
extra -= {"owner", "is_mount", "group"}

# not sure why jedi in particular ignores this (static?) method in 3.13
if (
tool == "jedi"
and sys.version_info[:2] == (3, 13)
and class_ in (trio.Path, trio.WindowsPath, trio.PosixPath)
):
missing.remove("with_segments")

# tuple subclasses are weird
if issubclass(class_, tuple):
if tool == "mypy" and issubclass(class_, tuple):
extra.remove("__reversed__")
missing.remove("__getnewargs__")

Expand All @@ -530,6 +510,22 @@ def lookup_symbol(symbol: str) -> dict[str, Any]: # type: ignore[misc, explicit
missing.discard("__annotate_func__")
missing.discard("__annotations_cache__")

if tool == "jedi" and class_ == trio.open_memory_channel:
# something is seriously wrong with jedi's understanding of open_memory_channel...
for attrib in (
"__add__",
"__contains__",
"__getitem__",
"__getnewargs__",
"__iter__",
"__len__",
"__mul__",
"__rmul__",
"count",
"index",
):
missing.remove(attrib)

if missing or extra: # pragma: no cover
errors[f"{module_name}.{class_name}"] = {
"missing": missing,
Expand Down
9 changes: 5 additions & 4 deletions src/trio/_tests/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,25 +252,26 @@ async def wait_send_all_might_not_block(self) -> None:
await _core.checkpoint()
await self.sleeper("wait_send_all_might_not_block")

async def send_all(self, data: bytes) -> None:
async def send_all(self, data: bytes | bytearray | memoryview[int]) -> None:
print(" --> transport_stream.send_all")
data_ = bytes(data)
with self._send_all_conflict_detector:
await _core.checkpoint()
await _core.checkpoint()
await self.sleeper("send_all")
self._conn.bio_write(data)
self._conn.bio_write(data_)
while True:
await self.sleeper("send_all")
try:
data = self._conn.recv(1)
data_ = self._conn.recv(1)
except SSL.ZeroReturnError:
self._conn.shutdown()
print("renegotiations:", self._conn.total_renegotiations())
break
except SSL.WantReadError:
break
else:
self._pending_cleartext += data
self._pending_cleartext += data_
self._lot.unpark_all()
await self.sleeper("send_all")
print(" <-- transport_stream.send_all finished")
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def close_hook() -> None:
async def test_MemoryReceiveStream() -> None:
mrs = MemoryReceiveStream()

async def do_receive_some(max_bytes: int | None) -> bytes:
async def do_receive_some(max_bytes: int | None) -> bytes | bytearray:
with assert_checkpoints():
return await mrs.receive_some(max_bytes)

Expand Down
2 changes: 1 addition & 1 deletion src/trio/_unix_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self, fd: int) -> None:
"another task is using this stream for receive",
)

async def send_all(self, data: bytes) -> None:
async def send_all(self, data: bytes | bytearray | memoryview) -> None:
with self._send_conflict_detector:
# have to check up front, because send_all(b"") on a closed pipe
# should raise
Expand Down
4 changes: 2 additions & 2 deletions src/trio/_windows_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, handle: int) -> None:
"another task is currently using this pipe",
)

async def send_all(self, data: bytes) -> None:
async def send_all(self, data: bytes | bytearray | memoryview[int]) -> None:
with self._conflict_detector:
if self._handle_holder.closed:
raise _core.ClosedResourceError("this pipe is already closed")
Expand Down Expand Up @@ -96,7 +96,7 @@ def __init__(self, handle: int) -> None:
"another task is currently using this pipe",
)

async def receive_some(self, max_bytes: int | None = None) -> bytes:
async def receive_some(self, max_bytes: int | None = None) -> bytes | bytearray:
with self._conflict_detector:
if self._handle_holder.closed:
raise _core.ClosedResourceError("this pipe is already closed")
Expand Down
Loading
Loading