From 86350ac7db69e74ab43ab32cc49f48d835f93b82 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:57:47 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.4.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.4.1) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7bd35a73..101620f7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ # * Run "pre-commit install". repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-toml - id: check-yaml @@ -16,14 +16,14 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.2 + rev: v0.4.1 hooks: - id: ruff args: [--fix, --show-fixes] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.9.0 hooks: - id: mypy additional_dependencies: ["pytest"] From 59ad80a864d413630988805c76a8178b1aa0262b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:57:56 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/tutorial1/echo/client.py | 1 + examples/tutorial1/echo/server.py | 1 + examples/tutorial2/webnotifier/app.py | 1 + examples/tutorial2/webnotifier/detector.py | 1 + src/asphalt/core/concurrent.py | 6 ++---- src/asphalt/core/context.py | 20 ++++++-------------- src/asphalt/core/utils.py | 8 ++------ 7 files changed, 14 insertions(+), 24 deletions(-) diff --git a/examples/tutorial1/echo/client.py b/examples/tutorial1/echo/client.py index aa8dc601..d5e4a839 100644 --- a/examples/tutorial1/echo/client.py +++ b/examples/tutorial1/echo/client.py @@ -1,4 +1,5 @@ """This is the client code for the Asphalt echo server tutorial.""" + import sys from asyncio import open_connection diff --git a/examples/tutorial1/echo/server.py b/examples/tutorial1/echo/server.py index a1a8f7ce..11a13642 100644 --- a/examples/tutorial1/echo/server.py +++ b/examples/tutorial1/echo/server.py @@ -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 diff --git a/examples/tutorial2/webnotifier/app.py b/examples/tutorial2/webnotifier/app.py index 28a0c67e..3a13d71e 100644 --- a/examples/tutorial2/webnotifier/app.py +++ b/examples/tutorial2/webnotifier/app.py @@ -1,4 +1,5 @@ """This is the root component for the Asphalt webnotifier tutorial.""" + # isort: off import logging from difflib import HtmlDiff diff --git a/examples/tutorial2/webnotifier/detector.py b/examples/tutorial2/webnotifier/detector.py index 9fe2f138..2ea54ccf 100644 --- a/examples/tutorial2/webnotifier/detector.py +++ b/examples/tutorial2/webnotifier/detector.py @@ -1,4 +1,5 @@ """This is the change detector component for the Asphalt webnotifier tutorial.""" + # isort: off from __future__ import annotations diff --git a/src/asphalt/core/concurrent.py b/src/asphalt/core/concurrent.py index 7351b6e9..be666a1a 100644 --- a/src/asphalt/core/concurrent.py +++ b/src/asphalt/core/concurrent.py @@ -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( diff --git a/src/asphalt/core/context.py b/src/asphalt/core/context.py index f2c99546..e21fa3e7 100644 --- a/src/asphalt/core/context.py +++ b/src/asphalt/core/context.py @@ -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): @@ -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): @@ -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( @@ -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]: diff --git a/src/asphalt/core/utils.py b/src/asphalt/core/utils.py index ad41c923..7077331b 100644 --- a/src/asphalt/core/utils.py +++ b/src/asphalt/core/utils.py @@ -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) @@ -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)})"