from collections.abc import Callable
from functools import wraps
def my_decorator[T, **P](fn: Callable[P, T]) -> Callable[P, T]:
click doesn't have a builtin date
type, only a datetime
. (They won't be adding one either.)
This litters my cli code with an annoying convert to date chore that I end up using all over the place:
@click.command()
Lightweight, generic result type à la Rust. (Sometimes you just want errors as values.)
Note: There is a full-on package that does this, with all the other Rust niceties of
.unwrap_or()
, etc. But if all you need is the basics, this is a zero-dependency approach in like 8 lines of actual code.
from dataclasses import dataclass