Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ repos:
hooks:
- id: commitizen
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.0
rev: v0.12.1
hooks:
# Run the linter
- id: ruff
- id: ruff-check
args:
- --fix
# Run the formatter
Expand Down
24 changes: 12 additions & 12 deletions mode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@
__all__ = [
"BaseSignal",
"BaseSignalT",
"Service",
"Signal",
"SignalT",
"SyncSignal",
"SyncSignalT",
"CrashingSupervisor",
"ForfeitOneForAllSupervisor",
"ForfeitOneForOneSupervisor",
"OneForAllSupervisor",
"OneForOneSupervisor",
"SupervisorStrategy",
"CrashingSupervisor",
"Seconds",
"Service",
"ServiceT",
"Signal",
"SignalT",
"SupervisorStrategy",
"SupervisorStrategyT",
"Seconds",
"want_seconds",
"SyncSignal",
"SyncSignalT",
"Worker",
"flight_recorder",
"get_logger",
"setup_logging",
"label",
"setup_logging",
"shortlabel",
"Worker",
"task",
"timer",
"flight_recorder",
"want_seconds",
]


Expand Down
56 changes: 28 additions & 28 deletions mode/locals.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,36 @@ class XProxy(MutableMappingRole, AsyncContextManagerRole):
from .utils.locals import LocalStack # XXX compat

__all__ = [
"LocalStack",
"Proxy",
"AwaitableRole",
"AwaitableProxy",
"CoroutineRole",
"CoroutineProxy",
"AsyncIterableRole",
"AsyncContextManagerProxy",
"AsyncContextManagerRole",
"AsyncGeneratorProxy",
"AsyncGeneratorRole",
"AsyncIterableProxy",
"AsyncIteratorRole",
"AsyncIterableRole",
"AsyncIteratorProxy",
"AsyncGeneratorRole",
"AsyncGeneratorProxy",
"SequenceRole",
"SequenceProxy",
"MutableSequenceRole",
"MutableSequenceProxy",
"SetRole",
"SetProxy",
"MutableSetRole",
"MutableSetProxy",
"ContextManagerRole",
"AsyncIteratorRole",
"AwaitableProxy",
"AwaitableRole",
"CallableProxy",
"CallableRole",
"ContextManagerProxy",
"AsyncContextManagerRole",
"AsyncContextManagerProxy",
"MappingRole",
"ContextManagerRole",
"CoroutineProxy",
"CoroutineRole",
"LocalStack",
"MappingProxy",
"MutableMappingRole",
"MappingRole",
"MutableMappingProxy",
"CallableRole",
"CallableProxy",
"MutableMappingRole",
"MutableSequenceProxy",
"MutableSequenceRole",
"MutableSetProxy",
"MutableSetRole",
"Proxy",
"SequenceProxy",
"SequenceRole",
"SetProxy",
"SetRole",
"maybe_evaluate",
]

Expand Down Expand Up @@ -188,11 +188,11 @@ class Proxy(Generic[T]):
# Code initially stolen from werkzeug.local.Proxy.
if not SLOTS_ISSUE_PRESENT and not PYPY: # pragma: no cover
__slots__ = (
"__local",
"__args",
"__kwargs",
"__finalizers",
"__dict__",
"__finalizers",
"__kwargs",
"__local",
)

def __init_subclass__(self, source: Optional[Type[T]] = None) -> None:
Expand Down
2 changes: 1 addition & 1 deletion mode/loop/eventlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import eventlet
except ImportError:
raise ImportError(
"Eventlet loop requires the eventlet library: " "pip install eventlet"
"Eventlet loop requires the eventlet library: pip install eventlet"
) from None
eventlet.monkey_patch()

Expand Down
4 changes: 2 additions & 2 deletions mode/loop/gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import gevent.monkey
except ImportError:
raise ImportError(
"Gevent loop requires the gevent library: " "pip install gevent"
"Gevent loop requires the gevent library: pip install gevent"
) from None
gevent.monkey.patch_all()

Expand All @@ -35,7 +35,7 @@
except ImportError:
raise
raise ImportError(
"Gevent loop requires the aiogevent library: " "pip install aiogevent"
"Gevent loop requires the aiogevent library: pip install aiogevent"
) from None


Expand Down
4 changes: 2 additions & 2 deletions mode/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from .utils.trees import Node
from .utils.types.trees import NodeT

__all__ = ["ServiceBase", "Service", "Diag", "task", "timer", "crontab"]
__all__ = ["Diag", "Service", "ServiceBase", "crontab", "task", "timer"]

ClockArg = Callable[[], float]

Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(
def _format_log(
self, severity: int, msg: str, *args: Any, **kwargs: Any
) -> str:
return f'[^{"-" * (self.beacon.depth - 1)}{self.shortlabel}]: {msg}'
return f"[^{'-' * (self.beacon.depth - 1)}{self.shortlabel}]: {msg}"

async def __aenter__(self) -> ServiceT:
await self.start()
Expand Down
4 changes: 2 additions & 2 deletions mode/supervisors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
__all__ = [
"ForfeitOneForAllSupervisor",
"ForfeitOneForOneSupervisor",
"SupervisorStrategy",
"OneForOneSupervisor",
"OneForAllSupervisor",
"OneForOneSupervisor",
"SupervisorStrategy",
]

logger = get_logger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions mode/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
from .utils.locks import Event

__all__ = [
"QueueServiceThread",
"QueuedMethod",
"WorkerThread",
"ServiceThread",
"QueueServiceThread",
"WorkerThread",
]


Expand Down
4 changes: 2 additions & 2 deletions mode/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from .supervisors import SupervisorStrategyT

__all__ = [
"BaseSignalT",
"DiagT",
"ServiceT",
"BaseSignalT",
"SignalHandlerT",
"SignalT",
"SyncSignalT",
"SupervisorStrategyT",
"SyncSignalT",
]
2 changes: 1 addition & 1 deletion mode/types/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
__all__ = [
"BaseSignalT",
"FilterReceiverMapping",
"SignalHandlerT",
"SignalHandlerRefT",
"SignalHandlerT",
"SignalT",
"SyncSignalT",
"T",
Expand Down
12 changes: 6 additions & 6 deletions mode/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ class LazySettings: ...


__all__ = [
"Heap",
"AttributeDict",
"AttributeDictMixin",
"DictAttribute",
"FastUserDict",
"FastUserSet",
"FastUserList",
"FastUserSet",
"Heap",
"LRUCache",
"ManagedUserDict",
"ManagedUserSet",
"AttributeDict",
"AttributeDictMixin",
"DictAttribute",
"force_mapping",
]

Expand Down Expand Up @@ -193,7 +193,7 @@ def fromkeys(
cls, iterable: Iterable[KT], value: VT = None
) -> "FastUserDict":
d = cls()
d.update({k: value for k in iterable})
d.update(dict.fromkeys(iterable, value))
return d

def __getitem__(self, key: KT) -> VT:
Expand Down
2 changes: 1 addition & 1 deletion mode/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import IO, AnyStr

__all__ = ["want_bytes", "want_str", "isatty"]
__all__ = ["isatty", "want_bytes", "want_str"]


def want_bytes(s: AnyStr) -> bytes:
Expand Down
2 changes: 1 addition & 1 deletion mode/utils/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def secs_for_next(cron_format: str, tz: Optional[tzinfo] = None) -> float:
# if not will set now to be the current timestamp (tz
# unaware)
# If we have tz, now will be a datetime, if not an integer
now = tz and datetime.now(tz) or now_ts
now = (tz and datetime.now(tz)) or now_ts
cron_it = croniter(cron_format, start_time=now)
return cast(float, cron_it.get_next(float)) - now_ts
2 changes: 1 addition & 1 deletion mode/utils/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def all_tasks(loop: asyncio.AbstractEventLoop) -> Set[asyncio.Task]:
"maybe_cancel",
"maybe_set_exception",
"maybe_set_result",
"stampede",
"notify",
"stampede",
]


Expand Down
23 changes: 14 additions & 9 deletions mode/utils/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def __init__(self, url: str) -> None:
__all__ = [
"FactoryMapping",
"SymbolArg",
"symbol_by_name",
"load_extension_class_names",
"load_extension_classes",
"cwd_in_path",
"import_from_cwd",
"load_extension_class_names",
"load_extension_classes",
"smart_import",
"symbol_by_name",
]

_T = TypeVar("_T")
Expand Down Expand Up @@ -113,7 +113,7 @@ def by_name(self, name: SymbolArg[_T]) -> _T:
alt = didyoumean(
self.aliases,
name_,
fmt_none=f'Available choices: {", ".join(self.aliases)}',
fmt_none=f"Available choices: {', '.join(self.aliases)}",
)
raise ModuleNotFoundError(
f"{name!r} is not a valid name. {alt}"
Expand Down Expand Up @@ -368,14 +368,19 @@ def load_extension_class_names(
```
"""
try:
from pkg_resources import iter_entry_points
from importlib.metadata import entry_points
except ImportError:
return

for ep in iter_entry_points(namespace):
yield RawEntrypointExtension(
ep.name, ":".join([ep.module_name, ep.attrs[0]])
)
eps = entry_points()
# For Python 3.10+, entry_points() returns an object with .select()
if hasattr(eps, "select"):
for ep in eps.select(group=namespace):
yield RawEntrypointExtension(ep.name, f"{ep.module}:{ep.attr}")
else:
# For Python 3.8/3.9, entry_points is a dict
for ep in eps.get(namespace, []):
yield RawEntrypointExtension(ep.name, f"{ep.module}:{ep.attr}")


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion mode/utils/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
from typing import Any, Callable, Optional

__all__ = ["clone_loop", "call_asap"]
__all__ = ["call_asap", "clone_loop"]


def _is_unix_loop(loop: asyncio.AbstractEventLoop) -> bool:
Expand Down
20 changes: 10 additions & 10 deletions mode/utils/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ def _is_class_var(x: Any) -> bool:


__all__ = [
"FieldMapping",
"DefaultsMapping",
"Unordered",
"KeywordReduce",
"FieldMapping",
"InvalidAnnotation",
"KeywordReduce",
"Unordered",
"abc_compatible_with_init_subclass",
"qualname",
"shortname",
"annotations",
"cached_property",
"canoname",
"canonshortname",
"annotations",
"eval_type",
"iter_mro_reversed",
"guess_polymorphic_type",
"cached_property",
"iter_mro_reversed",
"label",
"qualname",
"shortlabel",
"shortname",
]

# Workaround for https://bugs.python.org/issue29581
Expand Down Expand Up @@ -230,7 +230,7 @@ def canoname(obj: Any, *, main_name: Optional[str] = None) -> str:
name = qualname(obj)
parts = name.split(".")
if parts[0] == "__main__":
return ".".join([main_name or _detect_main_name()] + parts[1:])
return ".".join([main_name or _detect_main_name(), *parts[1:]])
return name


Expand All @@ -239,7 +239,7 @@ def canonshortname(obj: Any, *, main_name: Optional[str] = None) -> str:
name = shortname(obj)
parts = name.split(".")
if parts[0] == "__main__":
return ".".join([main_name or _detect_main_name()] + parts[1:])
return ".".join([main_name or _detect_main_name(), *parts[1:]])
return name


Expand Down
Loading
Loading