From 53f5d2214b3984852bf1a2f8ddeefbb90ba8c9ae Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Tue, 5 Mar 2019 18:43:10 +0300 Subject: [PATCH] dont convert to optional, if anytype --- mypy_django_plugin/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mypy_django_plugin/helpers.py b/mypy_django_plugin/helpers.py index ee3a98b..90e49b4 100644 --- a/mypy_django_plugin/helpers.py +++ b/mypy_django_plugin/helpers.py @@ -254,7 +254,9 @@ def extract_primary_key_type_for_get(model: TypeInfo) -> Optional[Type]: return None -def make_optional(typ: Type): +def make_optional(typ: Type) -> UnionType: + if isinstance(typ, AnyType): + return typ return UnionType.make_union([typ, NoneTyp()])