Skip to content

Commit 10e7078

Browse files
committed
Public interface entirely unambiguously typed
1 parent aa708fe commit 10e7078

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.pyright]
2-
include = ["async_utils"]
2+
include = ["src"]
33
exclude = [
44
"**/__pycache__",
55
"build",

src/async_utils/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
import os
1515
import sys
1616

17-
vi = sys.version_info
17+
_vi = sys.version_info
1818

1919
# - Check use of concurrent.futures.Future before extending this version.
2020
# - update `_misc._ensure_annotations.py` before extending this version.
2121
# - ensure `task_cache.__WrappedSignature` still works
22-
if (vi.major, vi.minor) > (3, 13):
23-
msg = """This library is not tested for use on python versions above 3.13
22+
if (_vi.major, _vi.minor) > (3, 13):
23+
msg: str = """This library is not tested for use on python versions above 3.13
2424
This library relies on a few internal details that are not safe to rely upon
2525
without checking this consistently.
2626
"""

src/async_utils/bg_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init_subclass__(cls) -> t.Never:
3737
__final__ = True
3838

3939
def __init__(self, loop: asyncio.AbstractEventLoop) -> None:
40-
self._loop = loop
40+
self._loop: asyncio.AbstractEventLoop = loop
4141
self._futures: set[cf.Future[t.Any]] = set()
4242

4343
def schedule[T](self, coro: CoroReturning[T], /) -> cf.Future[T]:

src/async_utils/priority_sem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class PriorityWaiter:
3535
__slots__ = ("future", "ord")
3636

3737
def __init__(self, priority: int, ts: float, future: asyncio.Future[None], /) -> None:
38-
self.ord = (priority, ts)
39-
self.future = future
38+
self.future: asyncio.Future[None] = future
39+
self.ord: tuple[int, float] = (priority, ts)
4040

4141
def cancelled(self) -> bool:
4242
return self.future.cancelled()

src/async_utils/sig_service.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import signal
2020
import socket
2121
import sys
22-
from collections.abc import Callable
22+
from collections.abc import Callable, Sequence
2323
from types import FrameType
2424

2525
from . import _typings as t
@@ -32,9 +32,9 @@
3232
type _HANDLER = _HTC | int | signal.Handlers | None
3333

3434
type HandleableSignals = t.Literal["SIGINT", "SIGTERM", "SIGBREAK", "SIGHUP"]
35-
type SignalTuple = tuple[HandleableSignals, ...]
35+
type SignalSequence = Sequence[HandleableSignals]
3636

37-
default_handled: SignalTuple = "SIGINT", "SIGTERM", "SIGBREAK"
37+
default_handled: SignalSequence = "SIGINT", "SIGTERM", "SIGBREAK"
3838

3939

4040
class SpecialExit(enum.IntEnum):
@@ -57,11 +57,13 @@ def __init_subclass__(cls) -> t.Never:
5757

5858
__final__ = True
5959

60-
def __init__(self, signals: SignalTuple = default_handled, /) -> None:
60+
def __init__(self, signals: SignalSequence = default_handled, /) -> None:
6161
self._startup: list[StartStopCall] = []
6262
self._cbs: list[SignalCallback] = []
6363
self._joins: list[StartStopCall] = []
64-
self.ss, self.cs = socket.socketpair()
64+
ss, cs = socket.socketpair()
65+
self.ss: socket.socket = ss
66+
self.cs: socket.socket = cs
6567
self.ss.setblocking(False)
6668
self.cs.setblocking(False)
6769
sig_members = signal.Signals.__members__.items()

0 commit comments

Comments
 (0)