Taragolis commented on issue #26130:
URL: https://github.com/apache/airflow/issues/26130#issuecomment-1235616497

   > Attrs automatically works for subclasses, so those subclasses are attrs 
classes
   
   I mean this case
   
   ```python
   Python 3.9.10 (main, Feb 25 2022, 16:54:01) 
   Type 'copyright', 'credits' or 'license' for more information
   IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
   PyDev console: using IPython 8.4.0
   Python 3.9.10 (main, Feb 25 2022, 16:54:01) 
   [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
   
   import attr
   @attr.s(auto_attribs=True)
   class AAttr:
       x: int
       y: int = attr.field(init=False)
       def __attrs_post_init__(self):
           self.y = 42
           
   AAttr(x=1)
   Out[4]: AAttr(x=1, y=42)
   
   class BAttr(AAttr):
       z: int = attr.field(init=False)
       def __attrs_post_init__(self):
           super().__attrs_post_init__()
           self.z = 43
           
   BAttr(x=1)
   Out[6]: BAttr(x=1, y=42)
   
   @attr.s(auto_attribs=True)
   class CAttr(AAttr):
       z: int = attr.field(init=False)
       def __attrs_post_init__(self):
           super().__attrs_post_init__()
           self.z = 43
           
   CAttr(x=1)
   Out[8]: CAttr(x=1, y=42, z=43)
   ```
   
   But it mostly synthetic because  `BaseOperatorLink` not use any of the 
`__attrs_pre_init__`, `__attrs_post_init__`, `__attrs_init__` methods.
   
   I don't remember why decorator required however without this decorator this 
link wouldn't show any warnings. Might be also related to 
serialisation/deserialisation `cattr` issue
   
   
https://github.com/apache/airflow/blob/cc2c6621254b2a0086f2b3fc17dd5f4421df2970/airflow/sensors/external_task.py#L412-L422
   
   >But the bigger issue: We don't know what custom links might exist out in 
the wild, so we can't just blindly change the tech used without breaking 
someone's custom code.
   
   I think it main reason why we can't just replace `attrs` by `dataclasses`


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