Fix typing.Optional normalization.

This commit is contained in:
Alex RootJunior 2019-06-30 23:12:13 +03:00
parent af2573dbee
commit 43c565d39b
4 changed files with 326 additions and 318 deletions

View file

@ -3,7 +3,7 @@ from __future__ import annotations
import typing
from dataclasses import dataclass, field
from generator.normalizers import normalize_type, get_returning
from generator.normalizers import normalize_type, get_returning, normalize_optional
@dataclass
@ -21,10 +21,11 @@ class Annotation:
@property
def python_type(self) -> str:
return normalize_type(self.type, self.required)
result = normalize_type(self.type)
return normalize_optional(result, self.required)
@property
def python_argument(self):
def python_field(self):
result = f"{self.python_name}: {self.python_type}"
value = "" if self.required else "None"