From fc4dc2a8e7ac984590127fda7cb7cea1a6c25190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 14 Sep 2025 11:46:57 +0200 Subject: [PATCH] pre-commit refresh --- .pre-commit-config.yaml | 6 +++--- src/runboat/utils.py | 11 +++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23c4abf..06a20f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,14 +2,14 @@ default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-toml - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.9 + rev: v0.13.0 hooks: - - id: ruff + - id: ruff-check - id: ruff-format diff --git a/src/runboat/utils.py b/src/runboat/utils.py index 753b4d7..69703da 100644 --- a/src/runboat/utils.py +++ b/src/runboat/utils.py @@ -4,7 +4,7 @@ import re from collections.abc import AsyncGenerator, Awaitable, Callable, Generator, Iterator from concurrent.futures.thread import ThreadPoolExecutor from functools import wraps -from typing import Any, ParamSpec, TypeVar +from typing import Any _pool = ThreadPoolExecutor(max_workers=20, thread_name_prefix="sync_to_async") @@ -13,12 +13,7 @@ def slugify(s: str | int) -> str: return re.sub(r"[^a-z0-9]", "-", str(s).lower()) -P = ParamSpec("P") -R = TypeVar("R") -T = TypeVar("T") - - -def sync_to_async(func: Callable[P, R]) -> Callable[P, Awaitable[R]]: +def sync_to_async[**P, R](func: Callable[P, R]) -> Callable[P, Awaitable[R]]: @wraps(func) async def inner(*args: Any, **kwargs: Any) -> R: f = functools.partial(func, *args, **kwargs) @@ -27,7 +22,7 @@ def sync_to_async(func: Callable[P, R]) -> Callable[P, Awaitable[R]]: return inner -def sync_to_async_iterator( +def sync_to_async_iterator[**P, R]( iterator_func: Callable[P, Generator[R]], ) -> Callable[P, AsyncGenerator[R]]: @sync_to_async