Skip to content

Commit c683ba7

Browse files
committed
fix: qa warns from pyright
1 parent 48e8858 commit c683ba7

3 files changed

Lines changed: 23 additions & 21 deletions

File tree

mode/locals.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class XProxy(MutableMappingRole, AsyncContextManagerRole):
9393
)
9494
from contextlib import AbstractAsyncContextManager, AbstractContextManager
9595
from functools import wraps
96-
from types import GetSetDescriptorType, TracebackType
96+
from types import CoroutineType, GetSetDescriptorType, TracebackType
9797
from typing import (
9898
Any,
9999
Callable,
@@ -479,21 +479,21 @@ def _get_generator(self) -> AsyncGenerator[T_co, T_contra]:
479479
obj = self._get_current_object() # type: ignore
480480
return cast(AsyncGenerator[T_co, T_contra], obj)
481481

482-
def __anext__(self) -> Awaitable[T_co]:
482+
def __anext__(self) -> CoroutineType[Any, Any, T_co]:
483483
return self._get_generator().__anext__()
484484

485-
def asend(self, value: T_contra) -> Awaitable[T_co]:
485+
def asend(self, value: T_contra) -> CoroutineType[Any, Any, T_co]:
486486
return self._get_generator().asend(value)
487487

488488
def athrow(
489489
self,
490490
typ: type[BaseException],
491491
val: Optional[BaseException] = None,
492492
tb: Optional[TracebackType] = None,
493-
) -> Awaitable[T_co]:
493+
) -> CoroutineType[Any, Any, T_co]:
494494
return self._get_generator().athrow(typ, val, tb)
495495

496-
def aclose(self) -> Awaitable[None]:
496+
def aclose(self) -> CoroutineType[Any, Any, None]:
497497
return self._get_generator().aclose()
498498

499499
def __aiter__(self) -> AsyncGenerator[T_co, T_contra]:
@@ -514,7 +514,7 @@ def _get_sequence(self) -> Sequence[T_co]:
514514
return cast(Sequence[T_co], obj)
515515

516516
@overload
517-
def __getitem__(self, i: int) -> T_co: ...
517+
def __getitem__(self, s: int) -> T_co: ...
518518

519519
@overload
520520
def __getitem__(self, s: slice) -> MutableSequence[T_co]: ...
@@ -556,13 +556,13 @@ def insert(self, index: int, object: T) -> None:
556556
self._get_sequence().insert(index, object)
557557

558558
@overload
559-
def __setitem__(self, i: int, o: T) -> None: ...
559+
def __setitem__(self, s: int, o: T) -> None: ...
560560

561561
@overload
562562
def __setitem__(self, s: slice, o: Iterable[T]) -> None: ...
563563

564-
def __setitem__(self, index_or_slice: Any, o: Any) -> None:
565-
self._get_sequence().__setitem__(index_or_slice, o)
564+
def __setitem__(self, s: Any, o: Any) -> None:
565+
self._get_sequence().__setitem__(s, o)
566566

567567
@overload
568568
def __delitem__(self, i: int) -> None: ...
@@ -708,19 +708,19 @@ class ContextManagerProxy(
708708
class AsyncContextManagerRole(AbstractAsyncContextManager[T_co]):
709709
"""Role/Mixin for `contextlib.AbstractAsyncContextManager` proxy methods."""
710710

711-
def __aenter__(self) -> Awaitable[T_co]:
711+
def __aenter__(self) -> CoroutineType[Any, Any, T_co]:
712712
obj = self._get_current_object() # type: ignore
713-
return cast(Awaitable[T_co], obj.__aenter__())
713+
return cast(CoroutineType[Any, Any, T_co], obj.__aenter__())
714714

715715
def __aexit__(
716716
self,
717717
exc_type: Optional[type[BaseException]],
718718
exc_value: Optional[BaseException],
719719
traceback: Optional[TracebackType],
720-
) -> Awaitable[Optional[bool]]:
720+
) -> CoroutineType[Any, Any, Optional[bool]]:
721721
obj = self._get_current_object() # type: ignore
722722
val = obj.__aexit__(exc_type, exc_value, traceback)
723-
return cast(Awaitable[Optional[bool]], val)
723+
return cast(CoroutineType[Any, Any, Optional[bool]], val)
724724

725725

726726
class AsyncContextManagerProxy(

mode/signals.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections.abc import Iterable, Mapping, MutableSet
66
from functools import partial
77
from types import MethodType
8-
from typing import Any, Callable, Optional, cast, no_type_check
8+
from typing import Any, Callable, Optional, Union, cast, no_type_check
99
from weakref import ReferenceType, WeakMethod, ref
1010

1111
from .types.signals import (
@@ -16,7 +16,6 @@
1616
SignalT,
1717
SyncSignalT,
1818
T,
19-
T_contra,
2019
)
2120
from .utils.futures import maybe_async
2221

@@ -37,7 +36,7 @@ def __init__(
3736
loop: Optional[asyncio.AbstractEventLoop] = None,
3837
default_sender: Any = None,
3938
receivers: Optional[MutableSet[SignalHandlerRefT]] = None,
40-
filter_receivers: FilterReceiverMapping = None,
39+
filter_receivers: Union[FilterReceiverMapping, None] = None,
4140
) -> None:
4241
self.name = name or ""
4342
self.owner = owner
@@ -84,7 +83,7 @@ class X(Service):
8483
starting = Signal()
8584
8685
>>> X.starting
87-
<Signal: X.strting>
86+
<Signal: X.string>
8887
```
8988
"""
9089
if not self.name:
@@ -94,15 +93,18 @@ class X(Service):
9493
def unpack_sender_from_args(self, *args: Any) -> tuple[T, tuple[Any, ...]]:
9594
sender = self.default_sender
9695
if sender is None:
97-
if not args:
96+
if not args or len(args) == 0:
9897
raise TypeError("Signal.send requires at least one argument")
98+
9999
if len(args) > 1:
100100
sender, *args = args # type: ignore
101101
else:
102102
sender, args = args[0], ()
103103
return sender, args
104104

105-
def connect(self, fun: SignalHandlerT = None, **kwargs: Any) -> Callable:
105+
def connect(
106+
self, fun: Union[SignalHandlerT, None] = None, **kwargs: Any
107+
) -> Callable:
106108
if fun is not None:
107109
return self._connect(fun, **kwargs)
108110
return partial(self._connect, **kwargs)
@@ -134,7 +136,7 @@ def disconnect(
134136
except ValueError:
135137
pass
136138

137-
def iter_receivers(self, sender: T_contra) -> Iterable[SignalHandlerT]:
139+
def iter_receivers(self, sender: object) -> Iterable[SignalHandlerT]:
138140
if self._receivers or self._filter_receivers:
139141
r = self._update_receivers(self._receivers)
140142
if sender is not None:

mode/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
loglevel: Optional[Union[str, int]] = None,
9999
logfile: Optional[Union[str, IO]] = None,
100100
redirect_stdouts: bool = True,
101-
redirect_stdouts_level: logging.Severity = None,
101+
redirect_stdouts_level: Optional[logging.Severity] = None,
102102
stdout: Optional[IO] = sys.stdout,
103103
stderr: Optional[IO] = sys.stderr,
104104
console_port: int = 50101,

0 commit comments

Comments
 (0)