You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/12/16 22:04:49 UTC

[GitHub] [airflow] ashb commented on a change in pull request #20034: Fix most MyPy errors for Airflow decorators

ashb commented on a change in pull request #20034:
URL: https://github.com/apache/airflow/pull/20034#discussion_r770950930



##########
File path: airflow/decorators/base.py
##########
@@ -101,22 +102,22 @@ class DecoratedOperator(BaseOperator):
     :type kwargs_to_upstream: dict
     """
 
-    template_fields: Iterable[str] = ('op_args', 'op_kwargs')
+    template_fields: Sequence[str] = ('op_args', 'op_kwargs')
     template_fields_renderers = {"op_args": "py", "op_kwargs": "py"}
 
     # since we won't mutate the arguments, we should just do the shallow copy
     # there are some cases we can't deepcopy the objects (e.g protobuf).
-    shallow_copy_attrs = ('python_callable',)
+    shallow_copy_attrs: Tuple[str, ...] = ('python_callable',)

Review comment:
       ```suggestion
       shallow_copy_attrs: Sequence[str] = ('python_callable',)
   ```

##########
File path: airflow/operators/python.py
##########
@@ -131,14 +131,14 @@ def my_python_callable(**kwargs):
     :type show_return_value_in_logs: bool
     """
 
-    template_fields = ('templates_dict', 'op_args', 'op_kwargs')
+    template_fields: Sequence[str] = ('templates_dict', 'op_args', 'op_kwargs')

Review comment:
       Do we need to specify the typing here? Doesn't it automatically take the typing from the parent class?

##########
File path: airflow/decorators/base.py
##########
@@ -101,22 +102,22 @@ class DecoratedOperator(BaseOperator):
     :type kwargs_to_upstream: dict
     """
 
-    template_fields = ('op_args', 'op_kwargs')
+    template_fields: Tuple[str, ...] = ('op_args', 'op_kwargs')
     template_fields_renderers = {"op_args": "py", "op_kwargs": "py"}
 
     # since we won't mutate the arguments, we should just do the shallow copy
     # there are some cases we can't deepcopy the objects (e.g protobuf).
-    shallow_copy_attrs = ('python_callable',)
+    shallow_copy_attrs: Tuple[str, ...] = ('python_callable',)
 
     def __init__(
         self,
         *,
         python_callable: Callable,
         task_id: str,
-        op_args: Tuple[Any],
+        op_args: List,

Review comment:
       This one is should share the type annotation with whatever PythonOperator `op_args` has.




-- 
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-unsubscribe@airflow.apache.org

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