Skip to content

Commit f4676d7

Browse files
committed
fix: get_annotated_constraint was not getting the max value
1 parent a33721e commit f4676d7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/aleph_client/commands/utils.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ def get_annotated_constraint(annotated_type: type, constraint_name: str) -> Any
100100
if not args:
101101
return None
102102

103-
for arg in args:
104-
if isinstance(arg, FieldInfo):
105-
value = getattr(arg, constraint_name, None)
106-
return value
103+
# We only care about FieldInfo, not the base type (like int)
104+
field_info = next((a for a in args if isinstance(a, FieldInfo)), None)
105+
if not field_info:
106+
return None
107+
108+
# FieldInfo stores constraint objects in its metadata list
109+
for meta in getattr(field_info, "metadata", []):
110+
if hasattr(meta, constraint_name):
111+
return getattr(meta, constraint_name)
112+
107113
return None
108114

109115

0 commit comments

Comments
 (0)