mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-14 18:54:28 +00:00
check if video recursion error coming from windows pathing
This commit is contained in:
parent
708e6e81d8
commit
6253c47e37
2 changed files with 11 additions and 7 deletions
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue