This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new ccc897afc1 Fix simple typo in the documentation. (#42058)
ccc897afc1 is described below

commit ccc897afc16abcd504781e46edf1810eabc501ae
Author: Hyunsoo Kang <hyunsoo.k...@mofl.ai>
AuthorDate: Wed Sep 11 02:15:46 2024 +0900

    Fix simple typo in the documentation. (#42058)
---
 docs/apache-airflow/howto/custom-operator.rst | 44 +++++++++++++--------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/docs/apache-airflow/howto/custom-operator.rst 
b/docs/apache-airflow/howto/custom-operator.rst
index ce32654a6b..f2b8db712d 100644
--- a/docs/apache-airflow/howto/custom-operator.rst
+++ b/docs/apache-airflow/howto/custom-operator.rst
@@ -281,44 +281,44 @@ templated field:
 .. code-block:: python
 
         class HelloOperator(BaseOperator):
-            template_fields = "field_a"
+            template_fields = "foo"
 
-            def __init__(field_a_id) -> None:  # <- should be def 
__init__(field_a)-> None
-                self.field_a = field_a_id  # <- should be self.field_a = 
field_a
+            def __init__(self, foo_id) -> None:  # should be def 
__init__(self, foo) -> None
+                self.foo = foo_id  # should be self.foo = foo
 
 2. Templated fields' instance members must be assigned with their 
corresponding parameter from the constructor,
 either by a direct assignment or by calling the parent's constructor (in which 
these fields are
 defined as ``template_fields``) with explicit an assignment of the parameter.
-The following example is invalid, as the instance member ``self.field_a`` is 
not assigned at all, despite being a
+The following example is invalid, as the instance member ``self.foo`` is not 
assigned at all, despite being a
 templated field:
 
 .. code-block:: python
 
         class HelloOperator(BaseOperator):
-            template_fields = ("field_a", "field_b")
+            template_fields = ("foo", "bar")
 
-            def __init__(field_a, field_b) -> None:
-                self.field_b = field_b
+            def __init__(self, foo, bar) -> None:
+                self.bar = bar
 
 
-The following example is also invalid, as the instance member ``self.field_a`` 
of ``MyHelloOperator`` is initialized
+The following example is also invalid, as the instance member ``self.foo`` of 
``MyHelloOperator`` is initialized
 implicitly as part of the ``kwargs`` passed to its parent constructor:
 
 .. code-block:: python
 
         class HelloOperator(BaseOperator):
-            template_fields = "field_a"
+            template_fields = "foo"
 
-            def __init__(field_a) -> None:
-                self.field_a = field_a
+            def __init__(self, foo) -> None:
+                self.foo = foo
 
 
         class MyHelloOperator(HelloOperator):
-            template_fields = ("field_a", "field_b")
+            template_fields = ("foo", "bar")
 
-            def __init__(field_b, **kwargs) -> None:  # <- should be def 
__init__(field_a, field_b, **kwargs)
-                super().__init__(**kwargs)  # <- should be 
super().__init__(field_a=field_a, **kwargs)
-                self.field_b = field_b
+            def __init__(self, bar, **kwargs) -> None:  # should be def 
__init__(self, foo, bar, **kwargs)
+                super().__init__(**kwargs)  # should be 
super().__init__(foo=foo, **kwargs)
+                self.bar = bar
 
 3. Applying actions on the parameter during the assignment in the constructor 
is not allowed.
 Any action on the value should be applied in the ``execute()`` method.
@@ -327,10 +327,10 @@ Therefore, the following example is invalid:
 .. code-block:: python
 
         class HelloOperator(BaseOperator):
-            template_fields = "field_a"
+            template_fields = "foo"
 
-            def __init__(field_a) -> None:
-                self.field_a = field_a.lower()  # <- assignment should be only 
self.field_a = field_a
+            def __init__(self, foo) -> None:
+                self.foo = foo.lower()  # assignment should be only self.foo = 
foo
 
 When an operator inherits from a base operator and does not have a constructor 
defined on its own, the limitations above
 do not apply. However, the templated fields must be set properly in the parent 
according to those limitations.
@@ -340,14 +340,14 @@ Thus, the following example is valid:
 .. code-block:: python
 
         class HelloOperator(BaseOperator):
-            template_fields = "field_a"
+            template_fields = "foo"
 
-            def __init__(field_a) -> None:
-                self.field_a = field_a
+            def __init__(self, foo) -> None:
+                self.foo = foo
 
 
         class MyHelloOperator(HelloOperator):
-            template_fields = "field_a"
+            template_fields = "foo"
 
 The limitations above are enforced by a pre-commit named 
'validate-operators-init'.
 

Reply via email to