Lee-W commented on issue #42495:
URL: https://github.com/apache/airflow/issues/42495#issuecomment-3401125996

   ```python
   from __future__ import annotations
   
   from datetime import datetime
   from typing import TYPE_CHECKING
   
   from airflow.sdk import DAG, Asset, AssetAlias
   from airflow.sdk.bases.operator import BaseOperator
   
   if TYPE_CHECKING:
       from airflow.utils.context import Context
   
   ALIAS_NAME = "some-alias"
   
   
   class CustomOperator(BaseOperator):
       def __init__(self, *args, **kwargs):
           kwargs["outlets"] = [AssetAlias(name=ALIAS_NAME)]
           super().__init__(*args, **kwargs)
   
       def execute(self, context: Context):
           new_outlets = [Asset("something")]
           for outlet in new_outlets:
               context["outlet_events"][AssetAlias(name=ALIAS_NAME)].add(outlet)
   
   
   with DAG("dataset_alias_dag", start_date=datetime(2023, 4, 20)) as dag:
       do_something = CustomOperator(task_id="do_something")
       do_something
   ```
   
   Update the code with the airflow 3 usage and test it with the latest main 
`69dfea43bf98a318628fae921fd7e92d73b06c77`, we no longer encounter the same 
error


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