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/31 16:45:53 UTC
[GitHub] [airflow] kaxil opened a new pull request #20613: Fix MyPy issues in ``airflow/macros``
kaxil opened a new pull request #20613:
URL: https://github.com/apache/airflow/pull/20613
**Before**:
```
root@57b2ac1779ad:/opt/airflow# mypy --namespace-packages airflow/macros
airflow/macros/__init__.py:83: error: Argument 1 to "diff_for_humans" of "DateTime" has incompatible type "Optional[datetime]"; expected "Optional[DateTime]"
return pendulum.instance(dt).diff_for_humans(since)
^
Found 1 error in 1 file (checked 2 source files)
```
**After**:
```
root@57b2ac1779ad:/opt/airflow# mypy --namespace-packages airflow/macros
Success: no issues found in 2 source files
```
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
--
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
[GitHub] [airflow] github-actions[bot] commented on pull request #20613: Fix MyPy issues in ``airflow/macros``
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #20613:
URL: https://github.com/apache/airflow/pull/20613#issuecomment-1003424654
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.
--
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
[GitHub] [airflow] potiuk commented on a change in pull request #20613: Fix MyPy issues in ``airflow/macros``
Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20613:
URL: https://github.com/apache/airflow/pull/20613#discussion_r777035348
##########
File path: airflow/macros/__init__.py
##########
@@ -66,7 +69,7 @@ def ds_format(ds: str, input_format: str, output_format: str) -> str:
return datetime.strptime(str(ds), input_format).strftime(output_format)
-def datetime_diff_for_humans(dt: Any, since: Optional[datetime] = None) -> str:
+def datetime_diff_for_humans(dt: Any, since: Optional[DateTime] = None) -> str:
Review comment:
Ah no. DateTime extends 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
[GitHub] [airflow] kaxil commented on a change in pull request #20613: Fix MyPy issues in ``airflow/macros``
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #20613:
URL: https://github.com/apache/airflow/pull/20613#discussion_r777037011
##########
File path: airflow/macros/__init__.py
##########
@@ -19,12 +19,15 @@
import uuid # noqa
from datetime import datetime, timedelta
from random import random # noqa
-from typing import Any, Optional
+from typing import TYPE_CHECKING, Any, Optional
import dateutil # noqa
from airflow.macros import hive # noqa
+if TYPE_CHECKING:
Review comment:
Updated
--
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
[GitHub] [airflow] potiuk commented on a change in pull request #20613: Fix MyPy issues in ``airflow/macros``
Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20613:
URL: https://github.com/apache/airflow/pull/20613#discussion_r777035164
##########
File path: airflow/macros/__init__.py
##########
@@ -19,12 +19,15 @@
import uuid # noqa
from datetime import datetime, timedelta
from random import random # noqa
-from typing import Any, Optional
+from typing import TYPE_CHECKING, Any, Optional
import dateutil # noqa
from airflow.macros import hive # noqa
+if TYPE_CHECKING:
Review comment:
Why type checking ? Should not we just import it as usual? i think it has no performance penalty (DateTime will be imported by the time it reaches here).
--
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
[GitHub] [airflow] potiuk commented on a change in pull request #20613: Fix MyPy issues in ``airflow/macros``
Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20613:
URL: https://github.com/apache/airflow/pull/20613#discussion_r777035187
##########
File path: airflow/macros/__init__.py
##########
@@ -66,7 +69,7 @@ def ds_format(ds: str, input_format: str, output_format: str) -> str:
return datetime.strptime(str(ds), input_format).strftime(output_format)
-def datetime_diff_for_humans(dt: Any, since: Optional[datetime] = None) -> str:
+def datetime_diff_for_humans(dt: Any, since: Optional[DateTime] = None) -> str:
Review comment:
```suggestion
def datetime_diff_for_humans(dt: Any, since: Optional[Union[DateTime, datetime]] = None) -> str:
```
--
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
[GitHub] [airflow] potiuk merged pull request #20613: Fix MyPy issues in ``airflow/macros``
Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #20613:
URL: https://github.com/apache/airflow/pull/20613
--
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