Skip to content

Commit

Permalink
Fixed pyright errors
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Oct 13, 2022
1 parent 8b2678a commit 3ce7bb8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 8 additions & 6 deletions src/anyio/_backends/_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from asyncio import sleep
from asyncio.base_events import _run_until_complete_cb # type: ignore[attr-defined]
from collections import OrderedDict, deque
from collections.abc import Iterable
from collections.abc import AsyncIterator, Iterable
from concurrent.futures import Future
from contextvars import Context, copy_context
from dataclasses import dataclass
Expand Down Expand Up @@ -1613,11 +1613,11 @@ class _SignalReceiver:
def __init__(self, signals: tuple[Signals, ...]):
self._signals = signals
self._loop = get_running_loop()
self._signal_queue: Deque[int] = deque()
self._signal_queue: Deque[Signals] = deque()
self._future: asyncio.Future = asyncio.Future()
self._handled_signals: set[int] = set()
self._handled_signals: set[Signals] = set()

def _deliver(self, signum: int) -> None:
def _deliver(self, signum: Signals) -> None:
self._signal_queue.append(signum)
if not self._future.done():
self._future.set_result(None)
Expand All @@ -1642,7 +1642,7 @@ def __exit__(
def __aiter__(self) -> _SignalReceiver:
return self

async def __anext__(self) -> int:
async def __anext__(self) -> Signals:
await AsyncIOBackend.checkpoint()
if not self._signal_queue:
self._future = asyncio.Future()
Expand Down Expand Up @@ -2206,7 +2206,9 @@ def current_default_thread_limiter(cls) -> CapacityLimiter:
return limiter

@classmethod
def open_signal_receiver(cls, *signals: Signals) -> ContextManager:
def open_signal_receiver(
cls, *signals: Signals
) -> ContextManager[AsyncIterator[Signals]]:
return _SignalReceiver(signals)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion src/anyio/_core/_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ._eventloop import get_async_backend


class _IgnoredTaskStatus(TaskStatus):
class _IgnoredTaskStatus(TaskStatus[object]):
def started(self, value: object = None) -> None:
pass

Expand Down
8 changes: 5 additions & 3 deletions src/anyio/abc/_eventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import math
from abc import ABCMeta, abstractmethod
from collections.abc import Awaitable, Mapping
from collections.abc import AsyncIterator, Awaitable, Mapping
from os import PathLike
from signal import Signals
from socket import AddressFamily, SocketKind, socket
Expand Down Expand Up @@ -48,7 +48,7 @@ class AsyncBackend(metaclass=ABCMeta):
def run(
cls,
func: Callable[..., Awaitable[T_Retval]],
args: tuple,
args: tuple[Any, ...],
kwargs: dict[str, Any],
options: dict[str, Any],
) -> T_Retval:
Expand Down Expand Up @@ -344,7 +344,9 @@ def current_default_thread_limiter(cls) -> CapacityLimiter:

@classmethod
@abstractmethod
def open_signal_receiver(cls, *signals: Signals) -> ContextManager:
def open_signal_receiver(
cls, *signals: Signals
) -> ContextManager[AsyncIterator[Signals]]:
pass

@classmethod
Expand Down
10 changes: 3 additions & 7 deletions src/anyio/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
from collections.abc import Iterator
from contextlib import contextmanager
from inspect import isasyncgenfunction, iscoroutinefunction
from typing import TYPE_CHECKING, Any, Dict, Tuple, cast
from typing import Any, Dict, Tuple, cast

import pytest
import sniffio
from _pytest.fixtures import FixtureRequest

from ._core._eventloop import get_all_backends, get_async_backend
from .abc import TestRunner

if TYPE_CHECKING:
from _pytest.config import Config

_current_runner: TestRunner | None = None


Expand Down Expand Up @@ -55,15 +51,15 @@ def get_runner(
sniffio.current_async_library_cvar.reset(token)


def pytest_configure(config: Config) -> None:
def pytest_configure(config: Any) -> None:
config.addinivalue_line(
"markers",
"anyio: mark the (coroutine function) test to be run "
"asynchronously via anyio.",
)


def pytest_fixture_setup(fixturedef: Any, request: FixtureRequest) -> None:
def pytest_fixture_setup(fixturedef: Any, request: Any) -> None:
def wrapper(*args, anyio_backend, **kwargs): # type: ignore[no-untyped-def]
backend_name, backend_options = extract_backend_and_options(anyio_backend)
if has_backend_arg:
Expand Down

0 comments on commit 3ce7bb8

Please sign in to comment.