Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 25, 2024
1 parent 3d1643f commit 59ca867
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions examples/tutorial1/echo/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This is the client code for the Asphalt echo server tutorial."""

import sys
from asyncio import open_connection

Expand Down
1 change: 1 addition & 0 deletions examples/tutorial1/echo/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This is the server code for the Asphalt echo server tutorial."""

from asyncio import StreamReader, StreamWriter, start_server

from asphalt.core import Component, Context, run_application
Expand Down
1 change: 1 addition & 0 deletions examples/tutorial2/webnotifier/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This is the root component for the Asphalt webnotifier tutorial."""

# isort: off
import logging
from difflib import HtmlDiff
Expand Down
1 change: 1 addition & 0 deletions examples/tutorial2/webnotifier/detector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This is the change detector component for the Asphalt webnotifier tutorial."""

# isort: off
from __future__ import annotations

Expand Down
6 changes: 2 additions & 4 deletions src/asphalt/core/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ def executor(
) -> Callable[
[Callable[Concatenate[Context, P], T_Retval]],
Callable[Concatenate[Context, P], T_Retval | Awaitable[T_Retval]],
]:
...
]: ...


@overload
def executor(
func_or_executor: Callable[Concatenate[Context, P], T_Retval],
) -> Callable[Concatenate[Context, P], T_Retval | Awaitable[T_Retval]]:
...
) -> Callable[Concatenate[Context, P], T_Retval | Awaitable[T_Retval]]: ...


def executor(
Expand Down
20 changes: 6 additions & 14 deletions src/asphalt/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ def __init__(self, type: type, name: str) -> None:
self.name = name

def __str__(self):
return "no matching resource was found for type={typename} name={self.name!r}".format(
self=self, typename=qualified_name(self.type)
)
return f"no matching resource was found for type={qualified_name(self.type)} name={self.name!r}"


class TeardownError(Exception):
Expand All @@ -207,9 +205,7 @@ def __str__(self):
"\n".join(format_exception(type(exc), exc, exc.__traceback__))
for exc in self.exceptions
)
return "{} exceptions(s) were raised by teardown callbacks:\n{}{}".format(
len(self.exceptions), separator, tracebacks
)
return f"{len(self.exceptions)} exceptions(s) were raised by teardown callbacks:\n{separator}{tracebacks}"


class NoCurrentContext(Exception):
Expand Down Expand Up @@ -845,15 +841,13 @@ def outer_wrapper(func: Callable[..., T_Retval]) -> Callable[..., Future[T_Retva
@overload
def context_teardown(
func: Callable[[T_Context], AsyncGenerator[None, Exception | None]],
) -> Callable[[T_Context], Coroutine[Any, Any, None]]:
...
) -> Callable[[T_Context], Coroutine[Any, Any, None]]: ...


@overload
def context_teardown(
func: Callable[[T_Self, T_Context], AsyncGenerator[None, Exception | None]],
) -> Callable[[T_Self, T_Context], Coroutine[Any, Any, None]]:
...
) -> Callable[[T_Self, T_Context], Coroutine[Any, Any, None]]: ...


def context_teardown(
Expand Down Expand Up @@ -993,13 +987,11 @@ def Dependency(name: str = "default") -> Any:
@overload
def inject(
func: Callable[P, Coroutine[Any, Any, T_Retval]],
) -> Callable[P, Coroutine[Any, Any, T_Retval]]:
...
) -> Callable[P, Coroutine[Any, Any, T_Retval]]: ...


@overload
def inject(func: Callable[P, T_Retval]) -> Callable[P, T_Retval]:
...
def inject(func: Callable[P, T_Retval]) -> Callable[P, T_Retval]: ...


def inject(func: Callable[P, Any]) -> Callable[P, Any]:
Expand Down
8 changes: 2 additions & 6 deletions src/asphalt/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def create_object(self, type: type | str, **constructor_kwargs) -> Any:
plugin_class = self.resolve(type)
if not isclass(plugin_class) or not issubclass(plugin_class, self.base_class):
raise TypeError(
"{} is not a subclass of {}".format(
qualified_name(plugin_class), qualified_name(self.base_class)
)
f"{qualified_name(plugin_class)} is not a subclass of {qualified_name(self.base_class)}"
)

return plugin_class(**constructor_kwargs)
Expand Down Expand Up @@ -210,6 +208,4 @@ def all(self) -> list[Any]:
return values

def __repr__(self):
return "{0.__class__.__name__}(namespace={0.namespace!r}, base_class={1})".format(
self, qualified_name(self.base_class)
)
return f"{self.__class__.__name__}(namespace={self.namespace!r}, base_class={qualified_name(self.base_class)})"

0 comments on commit 59ca867

Please sign in to comment.