Skip to content
Open
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
14 changes: 7 additions & 7 deletions guardrails/schema/rail_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,20 @@ def __repr__(self):
def extract_internal_format(format: str) -> Format:
fmt = Format()

internal, *custom_rest = format.split("; ")
internal, sep, custom = format.partition("; ")
fmt.custom_format = custom if sep else ""

fmt.custom_format = "; ".join(custom_rest)
internal_type, sep2, format_attr_rest = internal.partition(": ")

internal_type, *format_attr_rest = internal.split(": ")

if not RailTypes.get(internal_type):
rail_type = RailTypes.get(internal_type)
if not rail_type:
# This format wasn't manipulated by us,
# it just happened to match our pattern
fmt.custom_format = format
return fmt

fmt.internal_type = RailTypes.get(internal_type)
fmt.internal_format_attr = ": ".join(format_attr_rest)
fmt.internal_type = rail_type
fmt.internal_format_attr = format_attr_rest

return fmt

Expand Down