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/03 18:32:32 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #20000: Fix many of the mypy typing issues in airflow.models.dag

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



##########
File path: airflow/utils/timezone.py
##########
@@ -175,6 +175,16 @@ def parse(string: str, timezone=None) -> DateTime:
     return pendulum.parse(string, tz=timezone or TIMEZONE, strict=False)  # type: ignore
 
 
+@overload
+def coerce_datetime(v: None) -> None:
+    ...
+
+
+@overload
+def coerce_datetime(v: Union[dt.datetime, DateTime]) -> DateTime:
+    ...

Review comment:
       `pendulum.DateTime` is a stdlib `datetime` subclass, so this is equivalent to
   
   ```suggestion
   def coerce_datetime(v: dt.datetime) -> DateTime:
       ...
   ```
   
   same goes for the original annotation; it can just be `Optional[dt.datetime]`.




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