Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 17, 2024
1 parent f5e3036 commit 85fc72a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 29 deletions.
7 changes: 3 additions & 4 deletions src/plumpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import logging

# interfaces
from .controller import ProcessController
from .coordinator import Coordinator
from .events import *
from .exceptions import *
from .futures import *
Expand All @@ -18,10 +21,6 @@
from .utils import *
from .workchains import *

# interfaces
from .controller import ProcessController
from .coordinator import Coordinator

__all__ = (
events.__all__
+ exceptions.__all__
Expand Down
5 changes: 4 additions & 1 deletion src/plumpy/controller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

from collections.abc import Sequence
from typing import Any, Protocol

Expand Down Expand Up @@ -53,7 +56,7 @@ def kill_process(self, pid: 'PID_TYPE', msg: MessageType | None = None) -> Proce
...

def continue_process(
self, pid: 'PID_TYPE', tag: str|None = None, nowait: bool = False, no_reply: bool = False
self, pid: 'PID_TYPE', tag: str | None = None, nowait: bool = False, no_reply: bool = False
) -> ProcessResult | None:
"""
Continue the process
Expand Down
26 changes: 6 additions & 20 deletions src/plumpy/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import concurrent.futures
from typing import TYPE_CHECKING, Any, Callable, Hashable, Pattern, Protocol
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, Hashable, Pattern, Protocol

if TYPE_CHECKING:
# identifiers for subscribers
Expand All @@ -15,22 +15,8 @@
BroadcastSubscriber = Callable[['Coordinator', Any, Any, Any, ID_TYPE], Any]


class Communicator(Protocol):
def add_rpc_subscriber(self, subscriber: 'RpcSubscriber', identifier: 'ID_TYPE | None' = None) -> Any: ...

def add_broadcast_subscriber(
self, subscriber: 'BroadcastSubscriber', subject_filter: str | Pattern[str] | None = None, identifier=None
) -> Any: ...

def remove_rpc_subscriber(self, identifier): ...

def remove_broadcast_subscriber(self, identifier): ...

def broadcast_send(self, body, sender=None, subject=None, correlation_id=None) -> bool: ...


class Coordinator(Protocol):
def add_rpc_subscriber(self, subscriber: 'RpcSubscriber', identifier=None) -> Any: ...
def add_rpc_subscriber(self, subscriber: 'RpcSubscriber', identifier: 'ID_TYPE | None' = None) -> Any: ...

def add_broadcast_subscriber(
self,
Expand All @@ -41,9 +27,9 @@ def add_broadcast_subscriber(

def add_task_subscriber(self, subscriber: 'TaskSubscriber', identifier: 'ID_TYPE | None' = None) -> 'ID_TYPE': ...

def remove_rpc_subscriber(self, identifier): ...
def remove_rpc_subscriber(self, identifier: 'ID_TYPE | None') -> None: ...

def remove_broadcast_subscriber(self, identifier): ...
def remove_broadcast_subscriber(self, identifier: 'ID_TYPE | None') -> None: ...

def remove_task_subscriber(self, identifier: 'ID_TYPE') -> None: ...

Expand All @@ -52,7 +38,7 @@ def rpc_send(self, recipient_id: Hashable, msg: Any) -> Any: ...
def broadcast_send(
self,
body: Any | None,
sender: str | None = None,
sender: Hashable | str | None = None,
subject: str | None = None,
correlation_id: 'ID_TYPE | None' = None,
) -> Any: ...
Expand Down
4 changes: 2 additions & 2 deletions src/plumpy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

__all__ = [
'ClosedError',
'CoordinatorConnectionError',
'CoordinatorTimeoutError',
'InvalidStateError',
'KilledError',
'PersistenceError',
'UnsuccessfulResult',
'CoordinatorConnectionError',
'CoordinatorTimeoutError',
]


Expand Down
4 changes: 3 additions & 1 deletion src/plumpy/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Module containing future related methods and classes
"""

from __future__ import annotations

import asyncio
import contextlib
from typing import Any, Awaitable, Callable, Generator, Optional
Expand All @@ -18,7 +20,7 @@ class InvalidFutureError(Exception):


@contextlib.contextmanager
def capture_exceptions(future: Future[Any], ignore: tuple[type[BaseException], ...] = ()) -> Generator[None, Any, None]:
def capture_exceptions(future, ignore: tuple[type[BaseException], ...] = ()) -> Generator[None, Any, None]: # type: ignore[no-untyped-def]
"""
Capture any exceptions in the context and set them as the result of the given future
Expand Down
2 changes: 2 additions & 0 deletions src/plumpy/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Module for process level communication functions and classes"""

from __future__ import annotations

import asyncio
import logging
from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Union, cast
Expand Down
2 changes: 1 addition & 1 deletion src/plumpy/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ def _schedule_rpc(self, callback: Callable[..., Any], *args: Any, **kwargs: Any)
:return: a kiwi future that resolves to the outcome of the callback
"""
kiwi_future = concurrent.futures.Future()
kiwi_future = concurrent.futures.Future() # type: ignore[var-annotated]

async def run_callback() -> None:
with capture_exceptions(kiwi_future):
Expand Down
2 changes: 2 additions & 0 deletions src/plumpy/rmq/communications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Module for general kiwipy communication methods"""

from __future__ import annotations

import asyncio
import functools
from typing import TYPE_CHECKING, Any, Callable, Hashable, Optional
Expand Down
2 changes: 2 additions & 0 deletions src/plumpy/rmq/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# mypy: disable-error-code="no-untyped-def, no-untyped-call"
"""Module containing future related methods and classes"""

from __future__ import annotations

import asyncio
import concurrent.futures
from typing import Any
Expand Down

0 comments on commit 85fc72a

Please sign in to comment.