From 4d15afc4e3d50e325a64ec2aacf5c1fb07826b5a Mon Sep 17 00:00:00 2001 From: dotX12 <64792903+dotX12@users.noreply.github.com> Date: Fri, 21 Apr 2023 01:37:18 +0300 Subject: [PATCH 1/2] Fix Literal type --- pyfa_converter/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfa_converter/main.py b/pyfa_converter/main.py index d309374..2d26207 100644 --- a/pyfa_converter/main.py +++ b/pyfa_converter/main.py @@ -89,7 +89,7 @@ def make_form_parameter(field: ModelField) -> Any: the result of `Depends on` if it is. """ - if issubclass(field.type_, BaseModel): + if issubclass(type(field.type_), BaseModel): # This is a sub-model. assert hasattr(field.type_, _type_var_name), ( f"Sub-model class for {field.name} field must be decorated with" From 124f1d22e9dd407890a1131087d2f15078c28b58 Mon Sep 17 00:00:00 2001 From: dotX12 Date: Tue, 25 Apr 2023 01:25:30 +0300 Subject: [PATCH 2/2] fix https://github.com/dotX12/pyfa-converter/issues/21 literal type --- pyfa_converter/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyfa_converter/main.py b/pyfa_converter/main.py index 2d26207..f3a7505 100644 --- a/pyfa_converter/main.py +++ b/pyfa_converter/main.py @@ -89,13 +89,15 @@ def make_form_parameter(field: ModelField) -> Any: the result of `Depends on` if it is. """ - if issubclass(type(field.type_), BaseModel): + field_type = type(field.type_) if not isinstance(field.type_, type) else field.type_ + + if issubclass(field_type, BaseModel): # This is a sub-model. - assert hasattr(field.type_, _type_var_name), ( + assert hasattr(field_type, _type_var_name), ( f"Sub-model class for {field.name} field must be decorated with" f" `as_form` too." ) - attr = getattr(field.type_, _type_var_name) + attr = getattr(field_type, _type_var_name) return Depends(attr) # noqa else: return cls.param_maker(field=field, _type=_type)