Skip to content

Commit

Permalink
Go into even more detail in types after looking at changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Sep 29, 2024
1 parent 3c880fb commit 76538d8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
13 changes: 6 additions & 7 deletions src/trio/_tests/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ssl import SSLContext
from typing import (
TYPE_CHECKING,
Any,
NoReturn,
)

Expand Down Expand Up @@ -407,8 +406,8 @@ def ssl_wrap_pair(
client_transport: T_Stream,
server_transport: T_Stream,
*,
client_kwargs: dict[str, Any] | None = None,
server_kwargs: dict[str, Any] | None = None,
client_kwargs: dict[str, str | bytes | bool | None] | None = None,
server_kwargs: dict[str, str | bytes | bool | None] | None = None,
) -> tuple[SSLStream[T_Stream], SSLStream[T_Stream]]:
if server_kwargs is None:
server_kwargs = {}
Expand All @@ -418,13 +417,13 @@ def ssl_wrap_pair(
client_transport,
client_ctx,
server_hostname="trio-test-1.example.org",
**client_kwargs,
**client_kwargs, # type: ignore[arg-type]
)
server_ssl = SSLStream(
server_transport,
SERVER_CTX,
server_side=True,
**server_kwargs,
**server_kwargs, # type: ignore[arg-type]
)
return client_ssl, server_ssl

Expand All @@ -434,7 +433,7 @@ def ssl_wrap_pair(

def ssl_memory_stream_pair(
client_ctx: SSLContext,
**kwargs: dict[str, Any] | None,
**kwargs: dict[str, str | bytes | bool | None] | None,
) -> tuple[
SSLStream[MemoryStapledStream],
SSLStream[MemoryStapledStream],
Expand All @@ -448,7 +447,7 @@ def ssl_memory_stream_pair(

def ssl_lockstep_stream_pair(
client_ctx: SSLContext,
**kwargs: dict[str, Any] | None,
**kwargs: dict[str, str | bytes | bool | None] | None,
) -> tuple[
SSLStream[MyStapledStream],
SSLStream[MyStapledStream],
Expand Down
4 changes: 2 additions & 2 deletions src/trio/_tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def got_signal(proc: Process, sig: SignalType) -> bool:

@asynccontextmanager # type: ignore[misc] # Any in decorated
async def open_process_then_kill(
*args: Any, # noqa: ANN401 # Any used
*args: Any, # noqa: ANN401 # Any used, different OS -> different args
**kwargs: Any, # noqa: ANN401
) -> AsyncIterator[Process]:
proc = await open_process(*args, **kwargs)
Expand All @@ -105,7 +105,7 @@ async def open_process_then_kill(

@asynccontextmanager # type: ignore[misc] # Any in decorated
async def run_process_in_nursery(
*args: Any, # noqa: ANN401 # Any used
*args: Any, # noqa: ANN401 # Any used, different OS -> different args
**kwargs: Any, # noqa: ANN401
) -> AsyncIterator[Process]:
async with _core.open_nursery() as nursery:
Expand Down
11 changes: 7 additions & 4 deletions src/trio/_tests/test_unix_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from .._core._tests.tutil import gc_collect_harder, skip_if_fbsd_pipes_broken
from ..testing import check_one_way_stream, wait_all_tasks_blocked

if TYPE_CHECKING:
from .._file_io import _HasFileNo

posix = os.name == "posix"
pytestmark = pytest.mark.skipif(not posix, reason="posix only")

Expand Down Expand Up @@ -197,8 +200,8 @@ async def expect_closedresourceerror() -> None:

orig_wait_readable = _core._run.TheIOManager.wait_readable

async def patched_wait_readable(*args: object, **kwargs: object) -> None:
await orig_wait_readable(*args, **kwargs)
async def patched_wait_readable(fd: int | _HasFileNo) -> None:
await orig_wait_readable(fd)

Check warning on line 204 in src/trio/_tests/test_unix_pipes.py

View check run for this annotation

Codecov / codecov/patch

src/trio/_tests/test_unix_pipes.py#L204

Added line #L204 was not covered by tests
await r.aclose()

monkeypatch.setattr(_core._run.TheIOManager, "wait_readable", patched_wait_readable)
Expand All @@ -225,8 +228,8 @@ async def expect_closedresourceerror() -> None:

orig_wait_writable = _core._run.TheIOManager.wait_writable

async def patched_wait_writable(*args: object, **kwargs: object) -> None:
await orig_wait_writable(*args, **kwargs)
async def patched_wait_writable(fd: int | _HasFileNo) -> None:
await orig_wait_writable(fd)

Check warning on line 232 in src/trio/_tests/test_unix_pipes.py

View check run for this annotation

Codecov / codecov/patch

src/trio/_tests/test_unix_pipes.py#L232

Added line #L232 was not covered by tests
await s.aclose()

monkeypatch.setattr(_core._run.TheIOManager, "wait_writable", patched_wait_writable)
Expand Down
4 changes: 3 additions & 1 deletion src/trio/testing/_fake_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

from typing_extensions import Buffer, Self, TypeAlias

from trio._socket import AddressFormat

IPAddress: TypeAlias = Union[ipaddress.IPv4Address, ipaddress.IPv6Address]


Expand Down Expand Up @@ -313,7 +315,7 @@ async def _sendmsg(
buffers: Iterable[Buffer],
ancdata: Iterable[tuple[int, int, Buffer]] = (),
flags: int = 0,
address: object | None = None,
address: AddressFormat | None = None,
) -> int:
self._check_closed()

Expand Down

0 comments on commit 76538d8

Please sign in to comment.