Skip to content

Commit

Permalink
Improve typing for decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Dec 14, 2024
1 parent 66b6761 commit 1dcd10c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions things_cloud/models/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Callable
from datetime import datetime, time, timezone
from enum import Enum
from typing import Any, ParamSpec, TypeVar
from typing import Any, Concatenate, ParamSpec, TypeVar

import cattrs
from attrs import define, field
Expand Down Expand Up @@ -48,8 +48,14 @@ class Note:
_R = TypeVar("_R")


def mod(*field_names: str):
def decorate(func: Callable[..., _R]):
def mod(
*field_names: str,
) -> Callable[
[Callable[Concatenate[TodoItem, P], _R]], Callable[Concatenate[TodoItem, P], _R]
]:
def decorate(
func: Callable[Concatenate[TodoItem, P], _R],
) -> Callable[Concatenate[TodoItem, P], _R]:
def wrapper(self: TodoItem, *args: P.args, **kwargs: P.kwargs) -> _R:
# first we call the wrapped function,
# in case it throws an exception we don't want to modify
Expand Down

0 comments on commit 1dcd10c

Please sign in to comment.