Skip to content

Commit 9328e1b

Browse files
chore: add type hints to registry decorator
1 parent aabb214 commit 9328e1b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/adventofcode/registry/decorators.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
from collections.abc import Callable
12
from functools import partial, wraps
3+
from typing import ParamSpec, TypeAlias, TypeVar
24

35
from adventofcode.registry import registry
46
from adventofcode.registry.util import get_registry_key
57
from adventofcode.util.helpers import solution_timer
68

9+
R = TypeVar("R")
10+
P = ParamSpec("P")
11+
SolutionFunc: TypeAlias = Callable[P, R]
712

8-
def register_solution(year: int, day: int, part: int, version: str = "normal"):
13+
14+
def register_solution(
15+
year: int, day: int, part: int, version: str = "normal"
16+
) -> Callable[[SolutionFunc], SolutionFunc]:
917
"""Register a solution to the solution registry"""
1018

11-
def decorator(func):
19+
def decorator(func: SolutionFunc) -> SolutionFunc:
1220
partial_func = partial( # type: ignore
1321
solution_timer, func=func, year=year, day=day, part=part, version=version
1422
)

0 commit comments

Comments
 (0)