Viicos commented on PR #44249:
URL: https://github.com/apache/airflow/pull/44249#issuecomment-2493386351

   > I think this change is breaking far too much of an existing code base
   
   Since the release of 2.10, we only had one report 
(https://github.com/pydantic/pydantic/issues/10924) related to evaluation of 
forward annotations.
   
   > Pydantic is so popular and used in many, many dependencies
   
   We are aware of that, it is, in some cases, extremely challenging for us to 
make changes/cleanups, especially because in the field of forward annotations 
evaluation.
   
   The standard library utilities are far from perfect, so we had to implement 
our own logic to support edge cases that unfortunately led to a messy 
implementation, accepting invalid annotations to evaluate (this can be 
dangerous as names in forward annotations could resolve to the wrong type) [^1].
   
   > it's simply not reasonable to expect that existing released code will be 
updated
   
   Honestly, this requires a one line change on your end:
   
   
https://github.com/apache/airflow/blob/f33166a612218a10cee0e42cde36bc43fc184222/airflow/utils/log/logging_mixin.py#L68-L78
   
   Your usage of type annotations is inconsistent here, as you are mixing the 
new union syntax with `Optional`. Note that if this class were to be defined in 
the same module as 
[`TaskInstancePydantic`](https://github.com/apache/airflow/blob/1307e37bc6338c43aa5099752d012e244f8494ba/airflow/serialization/pydantic/taskinstance.py#L84),
 the issue would have appeared already.
   
   > So I would seriously reconsider that "fix" and revert it or workaround it 
in 2.10.2
   
   The "fix" is not actually a fix, but a complete refactor of our forward 
annotations evaluation. It's unfortunately not possible for us to "revert" it. 
The current implementation is vastly more accurate, and as I said above will 
avoid dangerous issues when forward annotations are silently _not_ resolved to 
the correct type. 
   
   [^1]: Read more 
[here](https://docs.pydantic.dev/latest/internals/resolving_annotations/#the-challenges-of-runtime-evaluation).


-- 
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]

Reply via email to