check if video recursion error coming from windows pathing

This commit is contained in:
sneakers-the-rat 2024-09-23 16:08:56 -07:00
parent 708e6e81d8
commit 6253c47e37
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
2 changed files with 11 additions and 7 deletions

View file

@ -142,7 +142,11 @@ class MarkedJson(BaseModel):
Try to cast to MarkedJson if applicable, otherwise return input
"""
if isinstance(value, dict) and "interface" in value and "value" in value:
value = MarkedJson(**value)
try:
value = MarkedJson(**value)
except ValidationError:
# fine, just not a MarkedJson dict even if it looks like one
return value
return value
@ -385,7 +389,7 @@ class Interface(ABC, Generic[T]):
"""
@classmethod
def mark_json(cls, array: Union[list, dict]) -> MarkedJson:
def mark_json(cls, array: Union[list, dict]) -> dict:
"""
When using ``model_dump_json`` with ``mark_interface: True`` in the ``context``,
add additional annotations that would allow the serialized array to be
@ -402,7 +406,7 @@ class Interface(ABC, Generic[T]):
'version': '1.2.2'},
'value': [1.0, 2.0]}
"""
return MarkedJson.model_construct(interface=cls.mark_interface(), value=array)
return {"interface": cls.mark_interface(), "value": array}
@classmethod
def interfaces(

View file

@ -23,13 +23,13 @@ def jsonize_array(value: Any, info: SerializationInfo) -> Union[list, dict]:
if info.context:
if info.context.get("mark_interface", False):
array = interface_cls.mark_json(array).model_dump()
array = interface_cls.mark_json(array)
if info.context.get("absolute_paths", False):
array = _absolutize_paths(array)
else:
relative_to = info.context.get("relative_to", ".")
array = _relativize_paths(array, relative_to)
# else:
# relative_to = info.context.get("relative_to", ".")
# array = _relativize_paths(array, relative_to)
return array