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/20 20:40:31 UTC

[GitHub] [airflow] subkanthi opened a new pull request #20434: Fix mypy tests operators

subkanthi opened a new pull request #20434:
URL: https://github.com/apache/airflow/pull/20434


   This PR is not complete, just wanted to check if this approach is fine to fix the errors where a dict is unpacked and passed to a function.
   `tests/providers/amazon/aws/operators/test_eks.py:62: error: Argument 2 to "EksCreateClusterOperator" has incompatible type "**Dict[str, Collection[Any]]";
   expected "str"
                   task_id=TASK_ID, **self.create_cluster_params, compute=None`
   
   TypedDict was the fix offered in mypy documents, the fix is a little bit verbose having to create a class, please let me know if there are other alternatives.
   
   <!--
   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] subkanthi commented on a change in pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#discussion_r773406629



##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -49,10 +52,16 @@
 NAME_LIST = ["foo", "bar", "baz", "qux"]
 
 
+class clusterParams(TypedDict):
+    cluster_name: str
+    cluster_role_arn: str
+    resources_vpc_config: Dict[Any, Any]
+
+
 class TestEksCreateClusterOperator(unittest.TestCase):
     def setUp(self) -> None:
         # Parameters which are needed to create a cluster.
-        self.create_cluster_params = dict(
+        self.create_cluster_params: clusterParams = dict(

Review comment:
       Fixed all errors.




-- 
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] subkanthi commented on a change in pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#discussion_r772656504



##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -49,10 +52,16 @@
 NAME_LIST = ["foo", "bar", "baz", "qux"]
 
 
+class clusterParams(TypedDict):
+    cluster_name: str
+    cluster_role_arn: str
+    resources_vpc_config: Dict[Any, Any]
+
+
 class TestEksCreateClusterOperator(unittest.TestCase):
     def setUp(self) -> None:
         # Parameters which are needed to create a cluster.
-        self.create_cluster_params = dict(
+        self.create_cluster_params: clusterParams = dict(

Review comment:
       @potiuk please let me know your thoughts on this approach for fixing dict unpacking.




-- 
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] uranusjr commented on a change in pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#discussion_r773553970



##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -49,10 +52,41 @@
 NAME_LIST = ["foo", "bar", "baz", "qux"]
 
 
+class clusterParams(TypedDict):

Review comment:
       ```suggestion
   class ClusterParams(TypedDict):
   ```
   
   Conventionally types should use CamelCases. (Same for all others below.)

##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -16,8 +16,11 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from typing import Any, Dict, List, Optional
 from unittest import mock
 
+from typing_extensions import TypedDict

Review comment:
       ```suggestion
   from airflow.typing_compat import TypedDict
   ```




-- 
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] subkanthi commented on a change in pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#discussion_r773922819



##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -16,8 +16,11 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from typing import Any, Dict, List, Optional
 from unittest import mock
 
+from typing_extensions import TypedDict

Review comment:
       Actually @uranusjr , looks like changing this to airflow.typing_compat seems to change the behavior, it introduced these errors
   
   `tests/providers/amazon/aws/operators/test_eks.py:88: error: Incompatible types in assignment (expression has type "Dict[str, Collection[Any]]", variable
   has type "ClusterParams")
               self.create_cluster_params: ClusterParams = dict(
                                                           ^
   tests/providers/amazon/aws/operators/test_eks.py:104: error: Incompatible types in assignment (expression has type "Dict[str, str]", variable has type
   "NodeGroupParams")
               self.base_nodegroup_params: NodeGroupParams = dict(
                                                             ^
   tests/providers/amazon/aws/operators/test_eks.py:125: error: Incompatible types in assignment (expression has type "Dict[str, Sequence[Any]]", variable has
   type "BaseFargateProfileParams")
               self.base_fargate_profile_params: BaseFargateProfileParams = dict(
                                                                            ^
   tests/providers/amazon/aws/operators/test_eks.py:183: error: Incompatible types in assignment (expression has type "Dict[str, Sequence[Any]]", variable has
   type "CreateFargateProfileParams")
               self.create_fargate_profile_params: CreateFargateProfileParams = dict(
                                                                                ^
   tests/providers/amazon/aws/operators/test_eks.py:205: error: Incompatible types in assignment (expression has type "Dict[str, Sequence[str]]", variable has
   type "CreateNodegroupParams")
   `




-- 
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] subkanthi commented on a change in pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#discussion_r773920784



##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -49,10 +52,41 @@
 NAME_LIST = ["foo", "bar", "baz", "qux"]
 
 
+class clusterParams(TypedDict):

Review comment:
       Fixed, thanks

##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -16,8 +16,11 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from typing import Any, Dict, List, Optional
 from unittest import mock
 
+from typing_extensions import TypedDict

Review comment:
       changed, thanks




-- 
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 #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#issuecomment-1000139888


   The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main 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 merged pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #20434:
URL: https://github.com/apache/airflow/pull/20434


   


-- 
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] subkanthi commented on a change in pull request #20434: Fix mypy tests/providers/amazon/aws/operators

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #20434:
URL: https://github.com/apache/airflow/pull/20434#discussion_r773922819



##########
File path: tests/providers/amazon/aws/operators/test_eks.py
##########
@@ -16,8 +16,11 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from typing import Any, Dict, List, Optional
 from unittest import mock
 
+from typing_extensions import TypedDict

Review comment:
       Actually @uranusjr , looks like changing this to airflow.typing_compat seems to change the behavior, it introduced these errors, will spend more time testing on both 3.6 and 3.8
   
   `tests/providers/amazon/aws/operators/test_eks.py:88: error: Incompatible types in assignment (expression has type "Dict[str, Collection[Any]]", variable
   has type "ClusterParams")
               self.create_cluster_params: ClusterParams = dict(
                                                           ^
   tests/providers/amazon/aws/operators/test_eks.py:104: error: Incompatible types in assignment (expression has type "Dict[str, str]", variable has type
   "NodeGroupParams")
               self.base_nodegroup_params: NodeGroupParams = dict(
                                                             ^
   tests/providers/amazon/aws/operators/test_eks.py:125: error: Incompatible types in assignment (expression has type "Dict[str, Sequence[Any]]", variable has
   type "BaseFargateProfileParams")
               self.base_fargate_profile_params: BaseFargateProfileParams = dict(
                                                                            ^
   tests/providers/amazon/aws/operators/test_eks.py:183: error: Incompatible types in assignment (expression has type "Dict[str, Sequence[Any]]", variable has
   type "CreateFargateProfileParams")
               self.create_fargate_profile_params: CreateFargateProfileParams = dict(
                                                                                ^
   tests/providers/amazon/aws/operators/test_eks.py:205: error: Incompatible types in assignment (expression has type "Dict[str, Sequence[str]]", variable has
   type "CreateNodegroupParams")
   `




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