Skip to content

Commit 8d267e9

Browse files
cosminachoclaude
andcommitted
Nit: use plain setattr in strip_disabled_fields
The previous object.__setattr__ was defensive bypass-validation, but every field in DISABLED_SAMPLING_PARAMS is declared as `<type> | None = None` on the underlying langchain subclasses, so None is always valid. `strip_disabled_fields` runs inside `@model_validator(mode="after")` and operates on the constructed pydantic model, so plain setattr already goes through `BaseModel.__setattr__` and respects field types. If a future caller tries to disable a non-nullable custom field, raising is the right behavior — better than silently bypassing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent afe4a3e commit 8d267e9

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/uipath/llm_client/utils/sampling.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,4 @@ def strip_disabled_fields(
132132
current,
133133
model_name,
134134
)
135-
# object.__setattr__ bypasses pydantic field validation in case the
136-
# field's declared type forbids None.
137-
object.__setattr__(instance, key, None)
135+
setattr(instance, key, None)

0 commit comments

Comments
 (0)