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/07 10:47:39 UTC

[GitHub] [airflow] ashb commented on a change in pull request #20000: Improve handling edge-cases in airlfow.models by applying mypy

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



##########
File path: airflow/models/baseoperator.py
##########
@@ -1301,8 +1305,13 @@ def run(
         from airflow.models import DagRun
         from airflow.utils.types import DagRunType
 
-        start_date = start_date or self.start_date
-        end_date = end_date or self.end_date or timezone.utcnow()
+        # Assertions for typing -- we need a dag, for this function, and when we have a DAG we are
+        # _guaranteed_ to have start_date (else we couldn't have been added to a DAG)
+        if TYPE_CHECKING:
+            assert self.start_date

Review comment:
       Added note to CONTRIBUTING doc. Didn't seem worth it to add a pre-commit check for it right now -- if it starts slipping through then we can add one at a later date.




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