potiuk commented on issue #14396:
URL: https://github.com/apache/airflow/issues/14396#issuecomment-785477989


   Seems like we end up with ever compiicating interfaces for no benefit other 
than "newer" approach where we have simpler alternative.
   
   Now, let me see how would you like to implement backward-compatibility of 
this (this is the more standard case of custom operator. This is just copy of 
what we have in our documentation:
   
   ```
   from airflow.models.baseoperator import BaseOperator
   from airflow.utils.decorators import apply_defaults
   
   class TaskOperator(BaseOperator):
   
       @apply_defaults
       def __init__(
               self,
               name: str,
               **kwargs) -> None:
           super().__init__(**kwargs)
           self.name = name
   
       def execute(self, context):
           message = "Task {}".format(context['ti'])
           print(message)
           return message
   ```
   
   What solution would be good here if we use Dataclasses, we want to keep 
backwards compatibility and we want to give users typehint for context.
   
   * TypedDict is easy - we change BaseOperator to have TypeDict context
   * Dataclass ????
   
   Any idea how to do it short of converting the Dataclass to TypeDict (which 
would defeat the purpose of having Dataclass in the first place).?
   
   
   
    


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to