Skip to content

Commit c5ae476

Browse files
Bump mypy from 0.931 to 1.9.0 (#197)
* Bump mypy from 0.931 to 1.9.0 Bumps [mypy](https://github.com/python/mypy) from 0.931 to 1.9.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v0.931...1.9.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * type fixes --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amethyst Reese <amethyst@n7.gg>
1 parent e6408ab commit c5ae476

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

aiomultiprocess/core.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import asyncio
55
import logging
66
import multiprocessing
7+
import multiprocessing.context
78
import multiprocessing.managers
89
import os
910
import sys
@@ -16,7 +17,9 @@
1617
# shared context for all multiprocessing primitives, for platform compatibility
1718
# "spawn" is default/required on windows and mac, but can't execute non-global functions
1819
# see https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
19-
context = multiprocessing.get_context(DEFAULT_START_METHOD)
20+
context: multiprocessing.context.BaseContext = multiprocessing.get_context(
21+
DEFAULT_START_METHOD
22+
)
2023
_manager = None
2124

2225
log = logging.getLogger(__name__)
@@ -80,12 +83,12 @@ class Process:
8083
def __init__(
8184
self,
8285
group: None = None,
83-
target: Callable = None,
84-
name: str = None,
85-
args: Sequence[Any] = None,
86-
kwargs: Dict[str, Any] = None,
86+
target: Optional[Callable] = None,
87+
name: Optional[str] = None,
88+
args: Optional[Sequence[Any]] = None,
89+
kwargs: Optional[Dict[str, Any]] = None,
8790
*,
88-
daemon: bool = None,
91+
daemon: Optional[bool] = None,
8992
initializer: Optional[Callable] = None,
9093
initargs: Sequence[Any] = (),
9194
loop_initializer: Optional[Callable] = None,
@@ -111,7 +114,7 @@ def __init__(
111114
initargs=initargs,
112115
loop_initializer=loop_initializer,
113116
)
114-
self.aio_process = context.Process(
117+
self.aio_process = context.Process( # type: ignore[attr-defined]
115118
group=group,
116119
target=process_target or Process.run_async,
117120
args=(self.unit,),
@@ -127,7 +130,7 @@ def __await__(self) -> Any:
127130
return self.join().__await__()
128131

129132
@staticmethod
130-
def run_async(unit: Unit) -> R:
133+
def run_async(unit: Unit) -> R: # type: ignore[type-var]
131134
"""Initialize the child process and event loop, then execute the coroutine."""
132135
try:
133136
if unit.loop_initializer is None:
@@ -152,7 +155,7 @@ def start(self) -> None:
152155
"""Start the child process."""
153156
return self.aio_process.start()
154157

155-
async def join(self, timeout: int = None) -> None:
158+
async def join(self, timeout: Optional[int] = None) -> None:
156159
"""Wait for the process to finish execution without blocking the main thread."""
157160
if not self.is_alive() and self.exitcode is None:
158161
raise ValueError("must start process before joining it")
@@ -216,7 +219,7 @@ def __init__(self, *args, **kwargs) -> None:
216219
self.unit.namespace.result = None
217220

218221
@staticmethod
219-
def run_async(unit: Unit) -> R:
222+
def run_async(unit: Unit) -> R: # type: ignore[type-var]
220223
"""Initialize the child process and event loop, then execute the coroutine."""
221224
try:
222225
result: R = Process.run_async(unit)
@@ -227,13 +230,13 @@ def run_async(unit: Unit) -> R:
227230
unit.namespace.result = e
228231
raise
229232

230-
async def join(self, timeout: int = None) -> Any:
233+
async def join(self, timeout: Optional[int] = None) -> Any:
231234
"""Wait for the worker to finish, and return the final result."""
232235
await super().join(timeout)
233236
return self.result
234237

235238
@property
236-
def result(self) -> R:
239+
def result(self) -> R: # type: ignore[type-var]
237240
"""Easy access to the resulting value from the coroutine."""
238241
if self.exitcode is None:
239242
raise ValueError("coroutine not completed")

aiomultiprocess/pool.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ class Pool:
150150

151151
def __init__(
152152
self,
153-
processes: int = None,
154-
initializer: Callable[..., None] = None,
153+
processes: Optional[int] = None,
154+
initializer: Optional[Callable[..., None]] = None,
155155
initargs: Sequence[Any] = (),
156156
maxtasksperchild: int = MAX_TASKS_PER_CHILD,
157157
childconcurrency: int = CHILD_CONCURRENCY,
158158
queuecount: Optional[int] = None,
159-
scheduler: Scheduler = None,
159+
scheduler: Optional[Scheduler] = None,
160160
loop_initializer: Optional[LoopInitializer] = None,
161161
exception_handler: Optional[Callable[[BaseException], None]] = None,
162162
) -> None:
@@ -316,8 +316,8 @@ async def results(self, tids: Sequence[TaskID]) -> Sequence[R]:
316316
async def apply(
317317
self,
318318
func: Callable[..., Awaitable[R]],
319-
args: Sequence[Any] = None,
320-
kwds: Dict[str, Any] = None,
319+
args: Optional[Sequence[Any]] = None,
320+
kwds: Optional[Dict[str, Any]] = None,
321321
) -> R:
322322
"""Run a single coroutine on the pool."""
323323
if not self.running:

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dev = [
3030
"flake8==7.0.0",
3131
"flake8-bugbear==24.4.21",
3232
"flit==3.9.0",
33-
"mypy==0.931",
33+
"mypy==1.9.0",
3434
"usort==1.0.8.post1",
3535
"uvloop==0.19.0; sys_platform != 'win32'",
3636
]

0 commit comments

Comments
 (0)