-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with parsing models on Python 3.9 #112
Conversation
@@ -35,7 +35,7 @@ | |||
except: # noqa | |||
# older python version | |||
NoneType = type(None) | |||
UnionType = type(int | str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this doesn't work with from __future__
is because it is not written inside an annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, missed that while in the rush
@@ -87,15 +87,20 @@ def parse_utc_timestamp(datetimestr: str): | |||
return datetime.fromisoformat(datetimestr.replace("Z", "+00:00")) | |||
|
|||
|
|||
def parse_value(name: str, value: Any, value_type: Type | str, default: Any = MISSING): | |||
def parse_value( | |||
name: str, value: Any, value_type: Union[Type, str], default: Any = MISSING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is inside an annotation so would have been fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, unrelated. The issue was the parsing of the actual annotations in this function itself.
Union types need to be written the oldskool way (even with annotations from future), otherwise our dynamic model creation does not work on python 3,9 causing import errors.