r-richmond commented on code in PR #55377:
URL: https://github.com/apache/airflow/pull/55377#discussion_r2330935095


##########
airflow-core/docs/core-concepts/operators.rst:
##########
@@ -84,11 +84,31 @@ Here, ``{{ ds }}`` is a templated variable, and because the 
``env`` parameter of
 
 You can also pass in a callable instead when Python is more readable than a 
Jinja template. The callable must accept two named arguments ``context`` and 
``jinja_env``:
 
+The ``context`` parameter is a dictionary-like object (``Dict[str, Any]``) 
that provides access to runtime information about the current task execution. 
You can access its contents using standard dictionary syntax 
(``context["key"]``) and it contains all the same variables that are available 
in Jinja templates. The context is read-only from the perspective of template 
rendering - while you can access and use its values, modifications won't affect 
the task execution environment.
+
+Key context variables include:
+
+- ``context["task"]``: The current task object (``BaseOperator``)
+- ``context["ti"]`` or ``context['task_instance']``: The task instance object 
(``TaskInstance``)
+- ``context["dag"]``: The DAG object containing this task
+- ``context["dag_run"]``: The current DAG run object
+- ``context["ds"]``: Data interval start date in YYYY-MM-DD format (``str``)
+- ``context["logical_date"]``: The logical date for this DAG run (``DateTime``)
+- ``context["run_id"]``: The run ID of the current DAG run (``str``)
+
+For a complete list of available context variables, see :ref:`Templates 
reference <templates:variables>`.
+
 .. code-block:: python
+    from typing import Any, Dict
+    import jinja2
 
-    def build_complex_command(context, jinja_env):
+
+    def build_complex_command(context: Dict[str, Any], jinja_env: 
jinja2.Environment) -> str:

Review Comment:
   Airflow has a typed dict 'Context' now so you can replace the arbitrary 
dict[str, Any] with that.
   
   Also it renders your above key examples a little duplicative. I'd update the 
above just to point to the Context definition so you can access the full list 
easier.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to