amoghrajesh commented on PR #45030:
URL: https://github.com/apache/airflow/pull/45030#issuecomment-2551528043
Simplifies it better now. This is a working example:
```
class A(BaseModel):
"""Schema for updating TaskInstance to a deferred state."""
trigger_kwargs: Annotated[dict[str, Any], Field(default_factory=dict)]
@field_validator("trigger_kwargs")
def validate_moment(cls, v):
if "moment" in v:
v["moment"] = AwareDatetimeAdapter.validate_strings(v["moment"])
return v
A(trigger_kwargs={"key": "value", "moment": "2024-12-18T00:00:00Z"})
Out[27]: A(trigger_kwargs={'key': 'value', 'moment': datetime.datetime(2024,
12, 18, 0, 0, tzinfo=TzInfo(UTC))})
A(trigger_kwargs={"key": "value", "moment": "2024-12-18T00:00:00"})
Traceback (most recent call last):
File
"/Users/amoghdesai/Documents/OSS/airflow/.venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py",
line 3550, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-28-ec6c9f9d0fce>", line 1, in <module>
A(trigger_kwargs={"key": "value", "moment": "2024-12-18T00:00:00"})
File
"/Users/amoghdesai/Documents/OSS/airflow/.venv/lib/python3.9/site-packages/pydantic/main.py",
line 214, in __init__
validated_self = self.__pydantic_validator__.validate_python(data,
self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for A
trigger_kwargs
Input should have timezone info [type=timezone_aware,
input_value='2024-12-18T00:00:00', input_type=str]
For further information visit
https://errors.pydantic.dev/2.10/v/timezone_aware
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]