Skip to content

Commit

Permalink
Try to get rid of more Anys
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Oct 27, 2024
1 parent deb1c13 commit 521c1b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
7 changes: 3 additions & 4 deletions src/trio/_core/_concat_tb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from types import TracebackType
from typing import Any, ClassVar, cast
from typing import ClassVar, cast

################################################################
# concat_tb
Expand Down Expand Up @@ -86,10 +86,9 @@ def copy_tb(base_tb: TracebackType, tb_next: TracebackType | None) -> TracebackT
def copy_tb(base_tb: TracebackType, tb_next: TracebackType | None) -> TracebackType:
# tputil.ProxyOperation is PyPy-only, and there's no way to specify
# cpython/pypy in current type checkers.
# Explicit "Any" is not allowed
def controller( # type: ignore[no-any-unimported,misc]
def controller( # type: ignore[no-any-unimported]
operation: tputil.ProxyOperation,
) -> Any | None:
) -> object | None:
# Rationale for pragma: I looked fairly carefully and tried a few
# things, and AFAICT it's not actually possible to get any
# 'opname' that isn't __getattr__ or __getattribute__. So there's
Expand Down
17 changes: 9 additions & 8 deletions src/trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@
# for some strange reason Sphinx works with outcome.Outcome, but not Outcome, in
# start_guest_run. Same with types.FrameType in iter_await_frames
import outcome
from typing_extensions import Self, TypeVar, TypeVarTuple, Unpack
from typing_extensions import ParamSpec, Self, TypeVar, TypeVarTuple, Unpack

PosArgT = TypeVarTuple("PosArgT")
StatusT = TypeVar("StatusT", default=None)
StatusT_contra = TypeVar("StatusT_contra", contravariant=True, default=None)
PS = ParamSpec("PS")
else:
from typing import TypeVar

StatusT = TypeVar("StatusT")
StatusT_contra = TypeVar("StatusT_contra", contravariant=True)
PS = TypeVar("PS")

# Explicit "Any" is not allowed
FnT = TypeVar("FnT", bound="Callable[..., Any]") # type: ignore[misc]
RetT = TypeVar("RetT")


Expand All @@ -103,8 +103,7 @@ class _NoStatus(metaclass=NoPublicConstructor):

# Decorator to mark methods public. This does nothing by itself, but
# trio/_tools/gen_exports.py looks for it.
# Explicit "Any" is not allowed
def _public(fn: FnT) -> FnT: # type: ignore[misc]
def _public(fn: Callable[PS, RetT]) -> Callable[PS, RetT]:
return fn


Expand Down Expand Up @@ -1290,7 +1289,7 @@ async def start( # type: ignore[misc]
async_fn: Callable[..., Awaitable[object]],
*args: object,
name: object = None,
) -> Any:
) -> Any | None:
r"""Creates and initializes a child task.
Like :meth:`start_soon`, but blocks until the new task has
Expand Down Expand Up @@ -1341,8 +1340,10 @@ async def async_fn(arg1, arg2, *, task_status=trio.TASK_STATUS_IGNORED):
# set strict_exception_groups = True to make sure we always unwrap
# *this* nursery's exceptiongroup
async with open_nursery(strict_exception_groups=True) as old_nursery:
# Explicit "Any" is not allowed
task_status: _TaskStatus[Any] = _TaskStatus(old_nursery, self) # type: ignore[misc]
task_status: _TaskStatus[object | None] = _TaskStatus(
old_nursery,
self,
)
thunk = functools.partial(async_fn, task_status=task_status)
task = GLOBAL_RUN_CONTEXT.runner.spawn_impl(
thunk,
Expand Down

0 comments on commit 521c1b7

Please sign in to comment.