added mypy checks and some typehint changes to conform

This commit is contained in:
collerek
2020-09-29 14:05:08 +02:00
parent 6d56ea5e30
commit 3caa87057e
23 changed files with 274 additions and 202 deletions

View File

@ -1,8 +1,8 @@
from typing import TYPE_CHECKING, Tuple, Type
from typing import TYPE_CHECKING, Tuple, Type, Optional
from weakref import proxy
import ormar
from ormar.fields.foreign_key import ForeignKeyField
from ormar.fields import BaseField
from ormar.fields.many_to_many import ManyToManyField
from ormar.relations import Relation
@ -12,7 +12,7 @@ if TYPE_CHECKING: # pragma no cover
def register_missing_relation(
parent: "Model", child: "Model", child_name: str
) -> Relation:
) -> Optional[Relation]:
ormar.models.expand_reverse_relationships(child.__class__)
name = parent.resolve_relation_name(parent, child)
field = parent.Meta.model_fields[name]
@ -22,7 +22,7 @@ def register_missing_relation(
def get_relations_sides_and_names(
to_field: Type[ForeignKeyField],
to_field: Type[BaseField],
parent: "Model",
child: "Model",
child_name: str,