Skip to content

Commit

Permalink
Bump mypy from 0.931 to 1.9.0 (#197)
Browse files Browse the repository at this point in the history
* 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] <[email protected]>

* type fixes

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Amethyst Reese <[email protected]>
  • Loading branch information
dependabot[bot] and amyreese authored Apr 23, 2024
1 parent e6408ab commit c5ae476
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
27 changes: 15 additions & 12 deletions aiomultiprocess/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
import logging
import multiprocessing
import multiprocessing.context
import multiprocessing.managers
import os
import sys
Expand All @@ -16,7 +17,9 @@
# shared context for all multiprocessing primitives, for platform compatibility
# "spawn" is default/required on windows and mac, but can't execute non-global functions
# see https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
context = multiprocessing.get_context(DEFAULT_START_METHOD)
context: multiprocessing.context.BaseContext = multiprocessing.get_context(
DEFAULT_START_METHOD
)
_manager = None

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -80,12 +83,12 @@ class Process:
def __init__(
self,
group: None = None,
target: Callable = None,
name: str = None,
args: Sequence[Any] = None,
kwargs: Dict[str, Any] = None,
target: Optional[Callable] = None,
name: Optional[str] = None,
args: Optional[Sequence[Any]] = None,
kwargs: Optional[Dict[str, Any]] = None,
*,
daemon: bool = None,
daemon: Optional[bool] = None,
initializer: Optional[Callable] = None,
initargs: Sequence[Any] = (),
loop_initializer: Optional[Callable] = None,
Expand All @@ -111,7 +114,7 @@ def __init__(
initargs=initargs,
loop_initializer=loop_initializer,
)
self.aio_process = context.Process(
self.aio_process = context.Process( # type: ignore[attr-defined]
group=group,
target=process_target or Process.run_async,
args=(self.unit,),
Expand All @@ -127,7 +130,7 @@ def __await__(self) -> Any:
return self.join().__await__()

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

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

@staticmethod
def run_async(unit: Unit) -> R:
def run_async(unit: Unit) -> R: # type: ignore[type-var]
"""Initialize the child process and event loop, then execute the coroutine."""
try:
result: R = Process.run_async(unit)
Expand All @@ -227,13 +230,13 @@ def run_async(unit: Unit) -> R:
unit.namespace.result = e
raise

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

@property
def result(self) -> R:
def result(self) -> R: # type: ignore[type-var]
"""Easy access to the resulting value from the coroutine."""
if self.exitcode is None:
raise ValueError("coroutine not completed")
Expand Down
10 changes: 5 additions & 5 deletions aiomultiprocess/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ class Pool:

def __init__(
self,
processes: int = None,
initializer: Callable[..., None] = None,
processes: Optional[int] = None,
initializer: Optional[Callable[..., None]] = None,
initargs: Sequence[Any] = (),
maxtasksperchild: int = MAX_TASKS_PER_CHILD,
childconcurrency: int = CHILD_CONCURRENCY,
queuecount: Optional[int] = None,
scheduler: Scheduler = None,
scheduler: Optional[Scheduler] = None,
loop_initializer: Optional[LoopInitializer] = None,
exception_handler: Optional[Callable[[BaseException], None]] = None,
) -> None:
Expand Down Expand Up @@ -316,8 +316,8 @@ async def results(self, tids: Sequence[TaskID]) -> Sequence[R]:
async def apply(
self,
func: Callable[..., Awaitable[R]],
args: Sequence[Any] = None,
kwds: Dict[str, Any] = None,
args: Optional[Sequence[Any]] = None,
kwds: Optional[Dict[str, Any]] = None,
) -> R:
"""Run a single coroutine on the pool."""
if not self.running:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dev = [
"flake8==7.0.0",
"flake8-bugbear==24.4.21",
"flit==3.9.0",
"mypy==0.931",
"mypy==1.9.0",
"usort==1.0.8.post1",
"uvloop==0.19.0; sys_platform != 'win32'",
]
Expand Down

0 comments on commit c5ae476

Please sign in to comment.