Skip to content

Commit

Permalink
style(black): apply new format style from black
Browse files Browse the repository at this point in the history
  • Loading branch information
manawasp committed Feb 22, 2024
1 parent 96b6267 commit 19eae80
Show file tree
Hide file tree
Showing 48 changed files with 203 additions and 313 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

check: # This job does nothing and is only used for the branch protection
name: ✅ Ensure the required checks passing
if: always()
Expand Down
1 change: 1 addition & 0 deletions mode/debug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Debugging utilities."""

import math
import signal
import traceback
Expand Down
19 changes: 7 additions & 12 deletions mode/locals.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class XProxy(MutableMappingRole, AsyncContextManagerRole):
... x['foo']
'value'
"""

import sys
import typing
from collections import deque
Expand Down Expand Up @@ -518,8 +519,7 @@ def _get_sequence(self) -> Sequence[T_co]:
return cast(Sequence[T_co], obj)

@overload
def __getitem__(self, i: int) -> T_co:
...
def __getitem__(self, i: int) -> T_co: ...

@overload # noqa: F811
def __getitem__(self, s: slice) -> MutableSequence[T_co]: # noqa: F811
Expand Down Expand Up @@ -562,8 +562,7 @@ def insert(self, index: int, object: T) -> None:
self._get_sequence().insert(index, object)

@overload
def __setitem__(self, i: int, o: T) -> None:
...
def __setitem__(self, i: int, o: T) -> None: ...

@overload # noqa: F811
def __setitem__(self, s: slice, o: Iterable[T]) -> None: # noqa: F811
Expand All @@ -573,8 +572,7 @@ def __setitem__(self, index_or_slice: Any, o: Any) -> None: # noqa: F811
self._get_sequence().__setitem__(index_or_slice, o)

@overload
def __delitem__(self, i: int) -> None:
...
def __delitem__(self, i: int) -> None: ...

@overload # noqa: F811
def __delitem__(self, i: slice) -> None: # noqa: F811
Expand Down Expand Up @@ -746,8 +744,7 @@ def __getitem__(self, key: KT) -> VT_co:
return self._get_mapping().__getitem__(key)

@overload
def get(self, k: KT) -> Optional[VT_co]:
...
def get(self, k: KT) -> Optional[VT_co]: ...

@overload # noqa: F811
def get(self, k: KT, default: Union[VT_co, T]) -> Union[VT_co, T]: # noqa: F811
Expand Down Expand Up @@ -796,8 +793,7 @@ def clear(self) -> None:
self._get_mapping().clear()

@overload
def pop(self, k: KT) -> VT:
...
def pop(self, k: KT) -> VT: ...

@overload # noqa: F811
def pop(self, k: KT, default: Union[VT, T] = ...) -> Union[VT, T]: # noqa: F811
Expand All @@ -813,8 +809,7 @@ def setdefault(self, k: KT, *args: Any) -> VT:
return self._get_mapping().setdefault(k, *args)

@overload
def update(self, __m: Mapping[KT, VT], **kwargs: VT) -> None:
...
def update(self, __m: Mapping[KT, VT], **kwargs: VT) -> None: ...

@overload # noqa: F811
def update(self, __m: Iterable[Tuple[KT, VT]], **kwargs: VT) -> None: # noqa: F811
Expand Down
1 change: 1 addition & 0 deletions mode/loop/_gevent_loop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Gevent loop customizations."""

import asyncio
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions mode/loop/eventlet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Enable :pypi:`eventlet` support for :mod:`asyncio`."""

import asyncio # noqa: E402,I100,I202
import os

Expand Down
1 change: 1 addition & 0 deletions mode/loop/gevent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Enable :pypi:`gevent` support for :mod:`asyncio`."""

import asyncio # noqa: E402,I100,I202
import os
import warnings
Expand Down
1 change: 1 addition & 0 deletions mode/loop/uvloop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Enable :pypi:`uvloop` as the event loop for :mod:`asyncio`."""

import asyncio

import uvloop
Expand Down
1 change: 1 addition & 0 deletions mode/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Works like a service, but delegates to underlying service object.
"""

import abc
from typing import Any, ContextManager, Optional

Expand Down
4 changes: 2 additions & 2 deletions mode/services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Async I/O services that can be started/stopped/shutdown."""

import asyncio
import logging
import sys
Expand Down Expand Up @@ -674,8 +675,7 @@ def __post_init__(self) -> None:
"""Additional user initialization."""
...

def on_init(self) -> None:
... # deprecated: use __post_init__
def on_init(self) -> None: ... # deprecated: use __post_init__

def on_init_dependencies(self) -> Iterable[ServiceT]:
"""Return list of service dependencies for this service."""
Expand Down
1 change: 1 addition & 0 deletions mode/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Signals - implementation of the Observer pattern."""

import asyncio
from collections import defaultdict
from functools import partial
Expand Down
1 change: 1 addition & 0 deletions mode/supervisors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
http://learnyousomeerlang.com/supervisors
"""

import asyncio
from typing import Any, Awaitable, Callable, Dict, List, Optional, Type

Expand Down
18 changes: 8 additions & 10 deletions mode/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Note: To stop something using the thread's loop, you have to
use the ``on_thread_stop`` callback instead of the on_stop callback.
"""

import asyncio
import sys
import threading
Expand Down Expand Up @@ -117,11 +118,9 @@ def __init__(
super().__init__(loop=self.thread_loop, **kwargs)
assert self._shutdown.loop is self.parent_loop

async def on_thread_started(self) -> None:
...
async def on_thread_started(self) -> None: ...

async def on_thread_stop(self) -> None:
...
async def on_thread_stop(self) -> None: ...

# The deal with asyncio.Event and threads.
#
Expand Down Expand Up @@ -226,14 +225,13 @@ def _stopped_set(self) -> None:
def set_shutdown(self) -> None:
self.parent_loop.call_soon_threadsafe(self._shutdown.set)

async def _stop_children(self) -> None:
... # called by thread instead of .stop()
async def _stop_children(self) -> None: ... # called by thread instead of .stop()

async def _stop_futures(self) -> None:
... # called by thread instead of .stop()
async def _stop_futures(self) -> None: ... # called by thread instead of .stop()

async def _stop_exit_stacks(self) -> None:
... # called by thread instead of .stop()
async def _stop_exit_stacks(
self,
) -> None: ... # called by thread instead of .stop()

async def _shutdown_thread(self) -> None:
await self.on_thread_stop()
Expand Down
1 change: 1 addition & 0 deletions mode/timers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""AsyncIO Timers."""

import asyncio
from itertools import count
from time import perf_counter
Expand Down
91 changes: 31 additions & 60 deletions mode/types/services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Type classes for :mod:`mode.services`."""

import abc
import asyncio
from typing import (
Expand Down Expand Up @@ -37,16 +38,13 @@ class DiagT(abc.ABC):
last_transition: MutableMapping[str, float]

@abc.abstractmethod
def __init__(self, service: "ServiceT") -> None:
...
def __init__(self, service: "ServiceT") -> None: ...

@abc.abstractmethod
def set_flag(self, flag: str) -> None:
...
def set_flag(self, flag: str) -> None: ...

@abc.abstractmethod
def unset_flag(self, flag: str) -> None:
...
def unset_flag(self, flag: str) -> None: ...


class ServiceT(AsyncContextManager):
Expand All @@ -70,117 +68,90 @@ class ServiceT(AsyncContextManager):
@abc.abstractmethod
def __init__(
self, *, beacon: NodeT = None, loop: asyncio.AbstractEventLoop = None
) -> None:
...
) -> None: ...

@abc.abstractmethod
def add_dependency(self, service: "ServiceT") -> "ServiceT":
...
def add_dependency(self, service: "ServiceT") -> "ServiceT": ...

@abc.abstractmethod
async def add_runtime_dependency(self, service: "ServiceT") -> "ServiceT":
...
async def add_runtime_dependency(self, service: "ServiceT") -> "ServiceT": ...

@abc.abstractmethod
async def add_async_context(self, context: AsyncContextManager) -> Any:
...
async def add_async_context(self, context: AsyncContextManager) -> Any: ...

@abc.abstractmethod
def add_context(self, context: ContextManager) -> Any:
...
def add_context(self, context: ContextManager) -> Any: ...

@abc.abstractmethod
async def start(self) -> None:
...
async def start(self) -> None: ...

@abc.abstractmethod
async def maybe_start(self) -> bool:
...
async def maybe_start(self) -> bool: ...

@abc.abstractmethod
async def crash(self, reason: BaseException) -> None:
...
async def crash(self, reason: BaseException) -> None: ...

@abc.abstractmethod
def _crash(self, reason: BaseException) -> None:
...
def _crash(self, reason: BaseException) -> None: ...

@abc.abstractmethod
async def stop(self) -> None:
...
async def stop(self) -> None: ...

@abc.abstractmethod
def service_reset(self) -> None:
...
def service_reset(self) -> None: ...

@abc.abstractmethod
async def restart(self) -> None:
...
async def restart(self) -> None: ...

@abc.abstractmethod
async def wait_until_stopped(self) -> None:
...
async def wait_until_stopped(self) -> None: ...

@abc.abstractmethod
def set_shutdown(self) -> None:
...
def set_shutdown(self) -> None: ...

@abc.abstractmethod
def _repr_info(self) -> str:
...
def _repr_info(self) -> str: ...

@property
@abc.abstractmethod
def started(self) -> bool:
...
def started(self) -> bool: ...

@property
@abc.abstractmethod
def crashed(self) -> bool:
...
def crashed(self) -> bool: ...

@property
@abc.abstractmethod
def should_stop(self) -> bool:
...
def should_stop(self) -> bool: ...

@property
@abc.abstractmethod
def state(self) -> str:
...
def state(self) -> str: ...

@property
@abc.abstractmethod
def label(self) -> str:
...
def label(self) -> str: ...

@property
@abc.abstractmethod
def shortlabel(self) -> str:
...
def shortlabel(self) -> str: ...

@property
def beacon(self) -> NodeT:
...
def beacon(self) -> NodeT: ...

@beacon.setter
def beacon(self, beacon: NodeT) -> None:
...
def beacon(self, beacon: NodeT) -> None: ...

@property
@abc.abstractmethod
def loop(self) -> asyncio.AbstractEventLoop:
...
def loop(self) -> asyncio.AbstractEventLoop: ...

@loop.setter
def loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None:
...
def loop(self, loop: Optional[asyncio.AbstractEventLoop]) -> None: ...

@property
@abc.abstractmethod
def crash_reason(self) -> Optional[BaseException]:
...
def crash_reason(self) -> Optional[BaseException]: ...

@crash_reason.setter
def crash_reason(self, reason: Optional[BaseException]) -> None:
...
def crash_reason(self, reason: Optional[BaseException]) -> None: ...
Loading

0 comments on commit 19eae80

Please sign in to comment.