|
@@ -2,15 +2,24 @@ import abc
|
|
|
from dataclasses import dataclass
|
|
|
from dataclasses_json import dataclass_json
|
|
|
from datetime import datetime
|
|
|
-from typing import List, Mapping, Optional
|
|
|
+from typing import List, Mapping, Optional, TypeVar, Type
|
|
|
|
|
|
import lc.config as c
|
|
|
|
|
|
+T = TypeVar("T")
|
|
|
+
|
|
|
|
|
|
class Request(metaclass=abc.ABCMeta):
|
|
|
@classmethod
|
|
|
@abc.abstractmethod
|
|
|
- def from_form(cls, form: Mapping[str, str]):
|
|
|
+ def from_form(cls: Type[T], form: Mapping[str, str]) -> T:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # technically this gets added by dataclass_json, but mypy isn't
|
|
|
+ # aware of it, so it's going to get declared here as though it
|
|
|
+ # weren't abstract and then dataclass_json will add it
|
|
|
+ @classmethod
|
|
|
+ def from_json(cls: Type[T], json: bytes) -> T:
|
|
|
pass
|
|
|
|
|
|
|