Resolve decode_state's field types from string annotations too
This commit was merged in pull request #122.
This commit is contained in:
@@ -4,6 +4,7 @@ import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import typing
|
||||
|
||||
RELOAD_FLAG = "--reloaded"
|
||||
|
||||
@@ -13,7 +14,7 @@ def decode_state(handed, kind):
|
||||
fields = json.loads(handed)
|
||||
except ValueError:
|
||||
return None
|
||||
shape = {field.name: field.type for field in dataclasses.fields(kind)}
|
||||
shape = typing.get_type_hints(kind)
|
||||
if not isinstance(fields, dict) or fields.keys() != shape.keys():
|
||||
return None
|
||||
if any(type(fields[name]) is not type_ for name, type_ in shape.items()):
|
||||
|
||||
Reference in New Issue
Block a user