Resolve decode_state's field types from string annotations too

This commit was merged in pull request #122.
This commit is contained in:
2026-09-29 10:29:08 +02:00
parent b69b37b334
commit d9058d2d7e
3 changed files with 12 additions and 3 deletions
+2 -1
View File
@@ -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()):