Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Field operations helper for StructuredModel comparisons."""

import inspect
from typing import Any, List, Type, get_args, get_origin
from typing import Any, List, Type


class FieldHelper:
Expand Down Expand Up @@ -44,48 +43,6 @@ def is_null_value(value: Any) -> bool:
return len(value.strip()) == 0
return False

@staticmethod
def is_structured_field_type(field_info) -> bool:
"""Check if a field represents a structured type that needs special handling.

Args:
field_info: Pydantic field info object

Returns:
True if the field is a List[StructuredModel] or StructuredModel type
"""
try:
# Get the field annotation
annotation = field_info.annotation

# Handle List[SomeType] annotations
if get_origin(annotation) is list:
args = get_args(annotation)
if args:
# Check if List element type is a StructuredModel subclass
element_type = args[0]
# Import here to avoid circular imports
from .structured_model import StructuredModel

if inspect.isclass(element_type) and issubclass(
element_type, StructuredModel
):
return True

# Handle direct StructuredModel annotations
elif inspect.isclass(annotation):
# Import here to avoid circular imports
from .structured_model import StructuredModel

if issubclass(annotation, StructuredModel):
return True

except (TypeError, AttributeError):
# If we can't determine the type, assume it's not structured
pass

return False

@staticmethod
def is_primitive_field(self_value: Any, other_value: Any) -> bool:
"""Check if a field should be treated as primitive (leaf node).
Expand Down