Not totally sure how to fix the issue with binding a TypeVar with Union types across the same function signature:
$ mypy ./examples
examples/timedelta_serializer.py:81: error: Dict entry 0 has
incompatible type "Type[timedelta]": "Callable[[int], timedelta]";
expected "Type[Any]":
"Callable[[Union[str, int, float, bool, datetime, Dict[Any, Any]]], Any]"
[dict-item]
timedelta: from_seconds,
^
examples/timedelta_serializer.py:90: error: Dict entry 0 has
incompatible type "str": "Callable[[int], timedelta]"; expected "str":
"Callable[[Union[str, int, float, bool, datetime, Dict[Any, Any]]], Any]"
[dict-item]
"duration": from_seconds,
^
Found 2 errors in 1 file (checked 6 source files)