From 951716cc9501b3c4dac2f459f9c3749f4c5b03fa Mon Sep 17 00:00:00 2001 From: Joshua Oreman Date: Mon, 5 Jun 2023 13:39:37 -0600 Subject: [PATCH] CI fixes --- .readthedocs.yml | 20 +++++++++++--------- docs/source/conf.py | 6 +++++- tricycle/_tests/test_tree_var.py | 6 +++--- tricycle/_tree_var.py | 19 ++++++++++++++----- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 4ccf144..9fde00e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,16 +1,18 @@ -# https://docs.readthedocs.io/en/latest/yaml-config.html +# https://docs.readthedocs.io/en/latest/config-file/index.html +version: 2 + formats: - htmlzip - epub -requirements_file: docs-requirements.txt - -# Currently RTD's default image only has 3.5 -# This gets us 3.6 (and hopefully 3.7 in the future) -# https://docs.readthedocs.io/en/latest/yaml-config.html#build-image build: - image: latest + os: "ubuntu-22.04" + tools: + python: "3.11" python: - version: 3.6 - pip_install: True + install: + - requirements: docs-requirements.txt + +sphinx: + fail_on_warning: true diff --git a/docs/source/conf.py b/docs/source/conf.py index d5c46e9..177e3b1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -44,7 +44,11 @@ ("py:obj", "bytes-like"), ("py:class", "None"), ("py:exc", "Anything else"), + ("py:class", "tricycle._rwlock._RWLockStatistics"), + ("py:class", "tricycle._tree_var.T"), + ("py:class", "tricycle._tree_var.U"), ] +default_role = "obj" # -- General configuration ------------------------------------------------ @@ -104,7 +108,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/tricycle/_tests/test_tree_var.py b/tricycle/_tests/test_tree_var.py index 2c413d9..0e54f34 100644 --- a/tricycle/_tests/test_tree_var.py +++ b/tricycle/_tests/test_tree_var.py @@ -66,7 +66,7 @@ def trivial_abort(_: object) -> trio.lowlevel.Abort: return trio.lowlevel.Abort.SUCCEEDED # pragma: no cover -async def test_treevar_follows_eventual_parent(): +async def test_treevar_follows_eventual_parent() -> None: tv1 = TreeVar[str]("tv1") async def manage_target(task_status: TaskStatus[trio.Nursery]) -> None: @@ -106,7 +106,7 @@ async def test_treevar_token_bound_to_task_that_obtained_it() -> None: tv1 = TreeVar[int]("tv1") token: Optional[TreeVarToken[int]] = None - async def get_token(): + async def get_token() -> None: nonlocal token token = tv1.set(10) try: @@ -141,4 +141,4 @@ async def run_sync(fn: Any, *args: Any) -> Any: tv1.being(40).__enter__, ): with pytest.raises(RuntimeError, match="must be called from async context"): - operation() + operation() # type: ignore diff --git a/tricycle/_tree_var.py b/tricycle/_tree_var.py index de01b5d..7e0acfe 100644 --- a/tricycle/_tree_var.py +++ b/tricycle/_tree_var.py @@ -5,7 +5,17 @@ import trio import weakref from contextlib import contextmanager -from typing import TypeVar, Generic, Any, MutableMapping, cast, overload +from typing import ( + TypeVar, + Generic, + Any, + Iterator, + MutableMapping, + Optional, + Union, + cast, + overload, +) T = TypeVar("T") U = TypeVar("U") @@ -106,7 +116,7 @@ def _fetch( self, for_task: trio.lowlevel.Task, current_task: Optional[trio.lowlevel.Task], - ) -> None: + ) -> _TreeVarState[T]: """Return the _TreeVarState associated with *for_task*, inheriting it from a parent nursery if necessary. """ @@ -190,9 +200,7 @@ def being(self, value: T) -> Iterator[None]: self.reset(token) @overload - def get_in( - self, task_or_nursery: Union[trio.lowlevel.Task, trio.Nursery] - ) -> T: + def get_in(self, task_or_nursery: Union[trio.lowlevel.Task, trio.Nursery]) -> T: ... @overload @@ -224,6 +232,7 @@ def get_in( if task is task_or_nursery: result = state.value_for_task else: + assert isinstance(task_or_nursery, trio.Nursery) result = state.value_for_children.get(task_or_nursery, state.value_for_task) if result is not MISSING: return result