diff options
| author | Dennis Fink | 2026-11-13 21:38:57 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-13 21:38:57 +0100 |
| commit | 497de85e7f2b91dc9e8ac546e9c1e41f9b6ae43f (patch) | |
| tree | 32de80f71f347c4fe77c05cd3813872bf46815a2 /webmentions_ssg/tasks/extension.py | |
| parent | defec7cc7d9f77f96ae08b3dac9652541e08222d (diff) | |
| download | webmentions-ssg-497de85e7f2b91dc9e8ac546e9c1e41f9b6ae43f.tar.gz webmentions-ssg-497de85e7f2b91dc9e8ac546e9c1e41f9b6ae43f.zip | |
refactor(core): use PEP 695 type parameters
Replace explicit `ParamSpec` and `TypeVar` declarations with inline
generic function parameters for Huey task decorators without changing
runtime behavior.
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/tasks/extension.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/webmentions_ssg/tasks/extension.py b/webmentions_ssg/tasks/extension.py index 2e78cc0..94875ff 100644 --- a/webmentions_ssg/tasks/extension.py +++ b/webmentions_ssg/tasks/extension.py @@ -8,7 +8,7 @@ from __future__ import annotations from collections.abc import Callable from functools import update_wrapper, wraps -from typing import Any, ParamSpec, TypeVar +from typing import Any from urllib.parse import urlsplit, urlunsplit from flask import Flask @@ -17,9 +17,6 @@ from huey.api import TaskWrapper from .json_serializer import JSONSerializer -P = ParamSpec("P") -R = TypeVar("R") - class _LazyTask: """Stable public task handle which follows the extension's current backend. @@ -145,7 +142,7 @@ class Huey: ) return self._huey - def _in_app_context(self, func: Callable[P, R]) -> Callable[P, R]: + def _in_app_context[**P, R](self, func: Callable[P, R]) -> Callable[P, R]: """Return a task wrapper that executes with the configured Flask app.""" @wraps(func) @@ -157,7 +154,7 @@ class Huey: return wrapped - def _decorate_task( + def _decorate_task[**P, R]( self, func: Callable[P, R], task_args: tuple[Any, ...], @@ -171,7 +168,7 @@ class Huey: handle.register() return handle - def task( + def task[**P, R]( self, *task_args: Any, **task_kwargs: Any ) -> Callable[[Callable[P, R]], _LazyTask]: """Declare a task even before :meth:`init_app` has run.""" @@ -181,7 +178,7 @@ class Huey: return decorator - def periodic_task( + def periodic_task[**P, R]( self, *task_args: Any, **task_kwargs: Any ) -> Callable[[Callable[P, R]], _LazyTask]: """Declare a periodic task against the current or next backend.""" |
