mirror of
https://gitlab.com/itsulu-odoo/runboat.git
synced 2026-05-30 23:41:27 +00:00
pre-commit refresh
This commit is contained in:
parent
7e160510a0
commit
fc4dc2a8e7
2 changed files with 6 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue