TobKed commented on a change in pull request #5965: [AIRFLOW-5359] Update type 
annotations in BaseOperator
URL: https://github.com/apache/airflow/pull/5965#discussion_r319684569
 
 

 ##########
 File path: airflow/models/baseoperator.py
 ##########
 @@ -262,38 +262,38 @@ def __init__(
         self,
         task_id: str,
         owner: str = configuration.conf.get('operators', 'DEFAULT_OWNER'),
-        email: Optional[str] = None,
+        email: str = None,
         email_on_retry: bool = True,
         email_on_failure: bool = True,
         retries: int = None,
         retry_delay: timedelta = timedelta(seconds=300),
         retry_exponential_backoff: bool = False,
-        max_retry_delay: Optional[datetime] = None,
-        start_date: Optional[datetime] = None,
-        end_date: Optional[datetime] = None,
+        max_retry_delay: datetime = None,
+        start_date: datetime = None,
+        end_date: datetime = None,
         schedule_interval=None,  # not hooked as of now
         depends_on_past: bool = False,
         wait_for_downstream: bool = False,
-        dag: Optional[DAG] = None,
-        params: Optional[Dict] = None,
-        default_args: Optional[Dict] = None,
+        dag: DAG = None,
+        params: Dict = None,
+        default_args: Dict = None,
         priority_weight: int = 1,
         weight_rule: str = WeightRule.DOWNSTREAM,
         queue: str = configuration.conf.get('celery', 'default_queue'),
         pool: str = Pool.DEFAULT_POOL_NAME,
-        sla: Optional[timedelta] = None,
-        execution_timeout: Optional[timedelta] = None,
-        on_failure_callback: Optional[Callable] = None,
-        on_success_callback: Optional[Callable] = None,
-        on_retry_callback: Optional[Callable] = None,
 
 Review comment:
   I've raised question about `Optional` type on Airflow Slack 
[here](https://apache-airflow.slack.com/archives/CCPRP7943/p1567155425013200).
   It was pointed there that arguments with a `None` default value are having 
an implicit `Optional[...]` type. It is default `mypy` behavior until it is not 
configured differently. Documentation about it here: [The mypy command line - 
None and Optional 
handling](https://mypy.readthedocs.io/en/stable/command_line.html#none-and-optional-handling)
 and here: [The mypy configuration file - None and Optional 
handling](https://mypy.readthedocs.io/en/stable/config_file.html#none-and-optional-handling).
   Due to this I assumed less code is better and I wanted to make annotations 
to be more consistent (some of them have `Optional` and some not). I had the 
same approach in another PR [[AIRFLOW-5360] Type annotations for 
BaseSensorOperator](https://github.com/apache/airflow/pull/5966/) and some 
future ones on which I am currently working.

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


With regards,
Apache Git Services

Reply via email to