improve some type annotations

This commit is contained in:
ducklet 2021-08-03 16:39:36 +02:00
parent 1413ba896f
commit 14f2395fa6
2 changed files with 19 additions and 4 deletions

View file

@ -16,6 +16,8 @@ from typing import (
from .types import ULID
T = TypeVar("T")
def annotations(tp: Type) -> Optional[tuple]:
return tp.__metadata__ if hasattr(tp, "__metadata__") else None
@ -102,7 +104,7 @@ def asplain(o, *, fields_: set = None) -> dict[str, Any]:
return d
def fromplain(cls, d: dict[str, Any]):
def fromplain(cls: Type[T], d: dict[str, Any]) -> T:
dd = {}
for f in fields(cls):
@ -232,7 +234,6 @@ class Movie:
self._is_lazy = False
T = TypeVar("T")
_RelationSentinel = object()
"""Mark a model field as containing external data.