Skip to content

Commit

Permalink
Bump dependencies from commit b161fe (#2819)
Browse files Browse the repository at this point in the history
* Dependency updates

* Remove type: ignores that now pass

* Fully type Outcome objects

* Handle ruff 0.1.0 changes

* Fail if ruff finds any errors in generated files, fix ruff tests

* Resolve type errors

* Fix type-ignore position

* ignore __copy__ and __deepcopy__

* Try fixing Sphinx build?

* Another shot at fixing Sphinx

* [pre-commit.ci] auto fixes from pre-commit.com hooks

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Spencer Brown <[email protected]>
Co-authored-by: jakkdl <[email protected]>
Co-authored-by: EXPLOSION <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Oct 20, 2023
1 parent b324b3a commit 3288cfc
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 58 deletions.
8 changes: 4 additions & 4 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ attrs==23.1.0
# via
# -r docs-requirements.in
# outcome
babel==2.12.1
babel==2.13.0
# via sphinx
certifi==2023.7.22
# via requests
Expand Down Expand Up @@ -53,9 +53,9 @@ jinja2==3.1.2
# towncrier
markupsafe==2.1.3
# via jinja2
outcome==1.2.0
outcome==1.3.0
# via -r docs-requirements.in
packaging==23.1
packaging==23.2
# via sphinx
pycparser==2.21
# via cffi
Expand Down Expand Up @@ -103,7 +103,7 @@ tomli==2.0.1
# via towncrier
towncrier==23.6.0
# via -r docs-requirements.in
urllib3==2.0.5
urllib3==2.0.7
# via requests
zipp==3.17.0
# via
Expand Down
4 changes: 0 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
# aliasing doesn't actually fix the warning for types.FrameType, but displaying
# "types.FrameType" is more helpful than just "frame"
"FrameType": "types.FrameType",
# unaliasing these makes intersphinx able to resolve them
"Outcome": "outcome.Outcome",
"Context": "OpenSSL.SSL.Context",
}

Expand All @@ -82,8 +80,6 @@ def autodoc_process_signature(
"""Modify found signatures to fix various issues."""
if signature is not None:
signature = signature.replace("~_contextvars.Context", "~contextvars.Context")
if name == "trio.lowlevel.start_guest_run":
signature = signature.replace("Outcome", "~outcome.Outcome")
if name == "trio.lowlevel.RunVar": # Typevar is not useful here.
signature = signature.replace(": ~trio._core._local.T", "")
if "_NoValue" in signature:
Expand Down
28 changes: 12 additions & 16 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#
astor==0.8.1
# via -r test-requirements.in
astroid==2.15.8
astroid==3.0.1
# via pylint
async-generator==1.10
# via -r test-requirements.in
attrs==23.1.0
# via
# -r test-requirements.in
# outcome
black==23.9.1 ; implementation_name == "cpython"
black==23.10.0 ; implementation_name == "cpython"
# via -r test-requirements.in
build==1.0.3
# via pip-tools
Expand All @@ -24,9 +24,9 @@ click==8.1.7
# via
# black
# pip-tools
codespell==2.2.5
codespell==2.2.6
# via -r test-requirements.in
coverage==7.3.1
coverage==7.3.2
# via -r test-requirements.in
cryptography==41.0.4
# via
Expand All @@ -50,13 +50,11 @@ iniconfig==2.0.0
# via pytest
isort==5.12.0
# via pylint
jedi==0.19.0
jedi==0.19.1
# via -r test-requirements.in
lazy-object-proxy==1.9.0
# via astroid
mccabe==0.7.0
# via pylint
mypy==1.5.1 ; implementation_name == "cpython"
mypy==1.6.0 ; implementation_name == "cpython"
# via -r test-requirements.in
mypy-extensions==1.0.0 ; implementation_name == "cpython"
# via
Expand All @@ -65,9 +63,9 @@ mypy-extensions==1.0.0 ; implementation_name == "cpython"
# mypy
nodeenv==1.8.0
# via pyright
outcome==1.2.0
outcome==1.3.0
# via -r test-requirements.in
packaging==23.1
packaging==23.2
# via
# black
# build
Expand All @@ -78,25 +76,25 @@ pathspec==0.11.2
# via black
pip-tools==7.3.0
# via -r test-requirements.in
platformdirs==3.10.0
platformdirs==3.11.0
# via
# black
# pylint
pluggy==1.3.0
# via pytest
pycparser==2.21
# via cffi
pylint==2.17.7
pylint==3.0.1
# via -r test-requirements.in
pyopenssl==23.2.0
# via -r test-requirements.in
pyproject-hooks==1.0.0
# via build
pyright==1.1.329
pyright==1.1.331
# via -r test-requirements.in
pytest==7.4.2
# via -r test-requirements.in
ruff==0.0.291
ruff==0.1.0
# via -r test-requirements.in
sniffio==1.3.0
# via -r test-requirements.in
Expand Down Expand Up @@ -130,8 +128,6 @@ typing-extensions==4.8.0
# pylint
wheel==0.41.2
# via pip-tools
wrapt==1.15.0
# via astroid
zipp==3.17.0
# via importlib-metadata

Expand Down
19 changes: 10 additions & 9 deletions trio/_core/_tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from contextlib import ExitStack, contextmanager
from math import inf
from typing import NoReturn, TypeVar
from typing import Any, NoReturn, TypeVar, cast

import outcome
import pytest
Expand Down Expand Up @@ -2121,12 +2121,13 @@ async def detachable_coroutine(
nursery.start_soon(detachable_coroutine, outcome.Value(None), "I'm free!")

# If we get here then Trio thinks the task has exited... but the coroutine
# is still iterable
# is still iterable. At that point anything can be sent into the coroutine, so the .coro type
# is wrong.
assert pdco_outcome is None
assert not_none(task).coro.send("be free!") == "I'm free!"
assert not_none(task).coro.send(cast(Any, "be free!")) == "I'm free!"
assert pdco_outcome == outcome.Value("be free!")
with pytest.raises(StopIteration):
not_none(task).coro.send(None)
not_none(task).coro.send(cast(Any, None))

# Check the exception paths too
task = None
Expand All @@ -2139,7 +2140,7 @@ async def detachable_coroutine(
assert not_none(task).coro.throw(throw_in) == "uh oh"
assert pdco_outcome == outcome.Error(throw_in)
with pytest.raises(StopIteration):
task.coro.send(None)
task.coro.send(cast(Any, None))

async def bad_detach() -> None:
async with _core.open_nursery():
Expand Down Expand Up @@ -2190,9 +2191,9 @@ def abort_fn(_: _core.RaiseCancelT) -> _core.Abort: # pragma: no cover
await wait_all_tasks_blocked()

# Okay, it's detached. Here's our coroutine runner:
assert not_none(task).coro.send("not trio!") == 1
assert not_none(task).coro.send(None) == 2
assert not_none(task).coro.send(None) == "byebye"
assert not_none(task).coro.send(cast(Any, "not trio!")) == 1
assert not_none(task).coro.send(cast(Any, None)) == 2
assert not_none(task).coro.send(cast(Any, None)) == "byebye"

# Now it's been reattached, and we can leave the nursery

Expand Down Expand Up @@ -2222,7 +2223,7 @@ def abort_fn(_: _core.RaiseCancelT) -> _core.Abort:
await wait_all_tasks_blocked()
assert task is not None
nursery.cancel_scope.cancel()
task.coro.send(None)
task.coro.send(cast(Any, None))

assert abort_fn_called

Expand Down
7 changes: 4 additions & 3 deletions trio/_core/_traps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from . import _run

if TYPE_CHECKING:
from outcome import Outcome
from typing_extensions import TypeAlias

from ._run import Task
Expand Down Expand Up @@ -182,10 +181,12 @@ def abort(inner_raise_cancel):
# Not exported in the trio._core namespace, but imported directly by _run.
@attr.s(frozen=True)
class PermanentlyDetachCoroutineObject:
final_outcome: Outcome = attr.ib()
final_outcome: outcome.Outcome[Any] = attr.ib()


async def permanently_detach_coroutine_object(final_outcome: Outcome) -> Any:
async def permanently_detach_coroutine_object(
final_outcome: outcome.Outcome[Any],
) -> Any:
"""Permanently detach the current task from the Trio scheduler.
Normally, a Trio task doesn't exit until its coroutine object exits. When
Expand Down
2 changes: 1 addition & 1 deletion trio/_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ async def open_file(


@overload
async def open_file(
async def open_file( # type: ignore[misc] # Any usage matches builtins.open().
file: _OpenFile,
mode: str,
buffering: int = -1,
Expand Down
2 changes: 1 addition & 1 deletion trio/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ async def open(
...

@overload
async def open(
async def open( # type: ignore[misc] # Any usage matches builtins.open().
self,
mode: str,
buffering: int = -1,
Expand Down
14 changes: 9 additions & 5 deletions trio/_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def send(__self, __bytes: Buffer, __flags: int = 0) -> Awaitable[int]:

@overload
async def sendto(
self, __data: Buffer, __address: tuple[Any, ...] | str | Buffer
self, __data: Buffer, __address: tuple[object, ...] | str | Buffer
) -> int:
...

Expand All @@ -703,7 +703,7 @@ async def sendto(
self,
__data: Buffer,
__flags: int,
__address: tuple[Any, ...] | str | Buffer,
__address: tuple[object, ...] | str | Buffer,
) -> int:
...

Expand Down Expand Up @@ -1167,13 +1167,13 @@ def send(__self, __bytes: Buffer, __flags: int = 0) -> Awaitable[int]:

@overload
async def sendto(
self, __data: Buffer, __address: tuple[Any, ...] | str | Buffer
self, __data: Buffer, __address: tuple[object, ...] | str | Buffer
) -> int:
...

@overload
async def sendto(
self, __data: Buffer, __flags: int, __address: tuple[Any, ...] | str | Buffer
self, __data: Buffer, __flags: int, __address: tuple[object, ...] | str | Buffer
) -> int:
...

Expand All @@ -1184,8 +1184,12 @@ async def sendto(self, *args: Any) -> int:
# and kwargs are not accepted
args_list = list(args)
args_list[-1] = await self._resolve_address_nocp(args[-1], local=False)
# args_list is Any, which isn't the signature of sendto().
# We don't care about invalid types, sendto() will do the checking.
return await self._nonblocking_helper(
_core.wait_writable, _stdlib_socket.socket.sendto, *args_list
_core.wait_writable,
_stdlib_socket.socket.sendto, # type: ignore[arg-type]
*args_list,
)

################################################################
Expand Down
2 changes: 1 addition & 1 deletion trio/_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def __init__(
self._incoming,
self._outgoing,
server_side=server_side,
server_hostname=server_hostname, # type: ignore[arg-type] # Typeshed bug, does accept bytes as well (typeshed#10590)
server_hostname=server_hostname,
)
# Tracks whether we've already done the initial handshake
self._handshook = _Once(self._do_handshake)
Expand Down
4 changes: 4 additions & 0 deletions trio/_tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ def lookup_symbol(symbol):
"__setstate__",
"__slots__",
"__weakref__",
# ignore errors about dunders inherited from stdlib that tools might
# not see
"__copy__",
"__deepcopy__",
}

# pypy seems to have some additional dunders that differ
Expand Down
14 changes: 7 additions & 7 deletions trio/_tests/tools/test_gen_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)

SOURCE = '''from _run import _public
from somewhere import Thing
from collections import Counter
class Test:
@_public
Expand All @@ -34,7 +34,7 @@ def public_func(self):
@ignore_this
@_public
@another_decorator
async def public_async_func(self) -> Thing:
async def public_async_func(self) -> Counter:
pass # no doc string
def not_public(self):
Expand All @@ -45,18 +45,18 @@ async def not_public_async(self):
'''

IMPORT_1 = """\
from somewhere import Thing
from collections import Counter
"""

IMPORT_2 = """\
from somewhere import Thing
from collections import Counter
import os
"""

IMPORT_3 = """\
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from somewhere import Thing
from collections import Counter
"""


Expand Down Expand Up @@ -90,7 +90,7 @@ def test_create_pass_through_args():


@skip_lints
@pytest.mark.parametrize("imports", ["", IMPORT_1, IMPORT_2, IMPORT_3])
@pytest.mark.parametrize("imports", [IMPORT_1, IMPORT_2, IMPORT_3])
def test_process(tmp_path, imports):
try:
import black # noqa: F401
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_run_black(tmp_path) -> None:

@skip_lints
def test_run_ruff(tmp_path) -> None:
"""Test that processing properly fails if black does."""
"""Test that processing properly fails if ruff does."""
try:
import ruff # noqa: F401
except ImportError as error: # pragma: no cover
Expand Down
Loading

0 comments on commit 3288cfc

Please sign in to comment.