You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/11/06 01:04:28 UTC

[PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

potiuk opened a new pull request, #35465:
URL: https://github.com/apache/airflow/pull/35465

   The mypy-providers specification has been wrong for tests/providers and tests/system/providers so a number of tests there has not been checked with type-hinting with MyPy. This PR fixes the specification and all the tests that were breaking mypy checks
   
   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   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 an 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/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ 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 changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+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 a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382737947


##########
tests/system/providers/google/cloud/automl/example_automl_translation.py:
##########
@@ -24,7 +24,7 @@
 from datetime import datetime
 from typing import cast
 
-from google.cloud import storage
+from google.cloud import storage  # type: ignore[attr-defined]

Review Comment:
   Hmm is the Google API module not annotated well or something? Maybe we should ignore the entire thing in Mypy config instead.



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382934504


##########
tests/system/providers/google/cloud/dataplex/example_dataplex.py:
##########
@@ -41,7 +41,7 @@
 from airflow.utils.trigger_rule import TriggerRule
 
 ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
-PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT")
+PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT") or "project_id"

Review Comment:
   Ah yeah. one place left 



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #35465:
URL: https://github.com/apache/airflow/pull/35465


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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382732300


##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_pipeline_job.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)
-# type: ignore[arg-type]
+
 

Review Comment:
   Same for multiple other files



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382737242


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_postgres.py:
##########
@@ -43,7 +43,7 @@
 from airflow.utils.trigger_rule import TriggerRule
 
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   This entire block should be removed now



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382933031


##########
tests/system/providers/google/cloud/data_loss_prevention/example_dlp_info_types.py:
##########
@@ -64,12 +65,14 @@
 OBJECT_GCS_OUTPUT_URI = OBJECT_GCS_URI + FILE_NAME
 
 CUSTOM_INFO_TYPE_ID = "custom_info_type"
-CUSTOM_INFO_TYPES = {
-    "large_custom_dictionary": {
-        "output_path": {"path": OBJECT_GCS_OUTPUT_URI},
-        "cloud_storage_file_set": {"url": OBJECT_GCS_URI + "*"},
+CUSTOM_INFO_TYPES = StoredInfoTypeConfig(
+    {
+        "large_custom_dictionary": {
+            "output_path": {"path": OBJECT_GCS_OUTPUT_URI},
+            "cloud_storage_file_set": {"url": OBJECT_GCS_URI + "*"},

Review Comment:
   Why not :) 



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382948106


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   Yeah. As a follow up PR maybe :).. This one is already huge.



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1383003418


##########
tests/providers/google/cloud/triggers/test_cloud_batch.py:
##########
@@ -69,10 +69,10 @@ async def test_trigger_on_success_yield_successfully(
         """
         Tests the CloudBatchJobFinishedTrigger fires once the job execution reaches a successful state.
         """
-        state = JobStatus.State.SUCCEEDED
+        state = JobStatus.State(JobStatus.State.SUCCEEDED)

Review Comment:
   Hmm, this seems a bit wrong, the previous code should work.



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #35465:
URL: https://github.com/apache/airflow/pull/35465#issuecomment-1795419133

   Look forward to merging those. The more we wait, the more likely we will have some new cases popping up


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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382930335


##########
tests/system/providers/google/cloud/automl/example_automl_translation.py:
##########
@@ -24,7 +24,7 @@
 from datetime import datetime
 from typing import cast
 
-from google.cloud import storage
+from google.cloud import storage  # type: ignore[attr-defined]

Review Comment:
   I tried to mov it to setup.cfg. it seems that storage is simply not yet mypy-ready:
   https://github.com/googleapis/python-storage/issues/393
   
   However, I have a hard time finding an easy way to exclude it in config more selectively. 
   I tried few ways and I seem I cannot do it other than (or I do not know a better way):
   
   I tried few approaches (ignore_missing_imports on google.cloud level, ignore_errors on google.cloud.storage level etc. etc. .. Seems that ignoring this one attr-defined is better as it is very selective (and also it is close to the source, which is kinda better than somewhat distant specification in config).
   
   I added a comment to https://github.com/googleapis/python-storage/issues/393 as an explanation and I think it should be "good-enough". 
   
   



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382928691


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   I think we could change a bit our ruff rules configuration for allow `TCH005` and maybe `TCH004`: https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
   
   ```toml
   # pyproject.toml
   
   extend-select = [
       ...
       "TCH",
   ]
   
   extend-ignore = [
       ...
       "TCH003",
   ]
   ```



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1383011291


##########
tests/providers/google/cloud/triggers/test_cloud_batch.py:
##########
@@ -69,10 +69,10 @@ async def test_trigger_on_success_yield_successfully(
         """
         Tests the CloudBatchJobFinishedTrigger fires once the job execution reaches a successful state.
         """
-        state = JobStatus.State.SUCCEEDED
+        state = JobStatus.State(JobStatus.State.SUCCEEDED)

Review Comment:
   Agree. But it does not :) ... Not sure what else I can do about it :)



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382945081


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   Yeah it was added by TCH001 and TCH002



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382729073


##########
tests/providers/amazon/aws/hooks/test_hooks_signature.py:
##########
@@ -187,10 +187,10 @@ def method2(self, spam: str):
     if not hooks:
         pytest.skip(reason=f"Module {hook_module!r} doesn't contain subclasses of `AwsGenericHook`.")
 
-    errors = []
+    errors: list[str] = []
     for hook, hook_name in hooks:
         is_valid, msg = validate_hook(hook, hook_name, hook_module)
-        if not is_valid:
+        if not is_valid and msg:
             errors.append(msg)

Review Comment:
   ```suggestion
       validation_results = (validate_hook(hook, hook_name, hook_module) for hook, hook_name in hooks)
       errors = [
           message
           for valid, message in validation_results
           if not valid and message
       ]
   ```



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382732049


##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_pipeline_job.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)
-# type: ignore[arg-type]
+
 

Review Comment:
   I think the “mypy ignore” comment above should be removed as well



##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_pipeline_job.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)
-# type: ignore[arg-type]
+
 

Review Comment:
   I think the “mypy ignore” comment above should be removed as well



##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_model_service.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)

Review Comment:
   same



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382932641


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   Ah yeah. That was automatically added by one of the linters after some import removal. removed those.



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382895098


##########
.pre-commit-config.yaml:
##########
@@ -1000,7 +1000,7 @@ repos:
         name: Run mypy for providers
         language: python
         entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
-        files: ^airflow/providers/.*\.py$|^tests/providers/\*\.py$|^tests/system/providers/\*\.py$
+        files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$

Review Comment:
   Well.. As we see here - seems we already had trouble with getting the regexp right :) .  I do not want to complicate it even more.... You know the saying "Have a problem? introduce regexp, now you have two problems..." 



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382941231


##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_pipeline_job.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)
-# type: ignore[arg-type]
+
 

Review Comment:
   Correct. I reviewed it everywhere
   
   



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382952833


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   Yeah! Sure. I though it might also reformat other parts and add additional changes in files from 0 to 9000 🤣 



##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   Yeah! Sure. I though it might also reformat other parts and add additional changes in files from 0 to 9000 🤣 



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382732086


##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_model_service.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)

Review Comment:
   same



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382737463


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   Same



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382726086


##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_mysql.py:
##########
@@ -42,8 +42,10 @@
 )
 from airflow.utils.trigger_rule import TriggerRule
 
+# mypy: disable-error-code="call-overload"
+
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   If there's nothing here, should we just remove it?



##########
tests/system/providers/google/cloud/dataplex/example_dataplex.py:
##########
@@ -41,7 +41,7 @@
 from airflow.utils.trigger_rule import TriggerRule
 
 ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
-PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT")
+PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT") or "project_id"

Review Comment:
   ```suggestion
   PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT", "project_id")
   ```
   
   should we make it this way for consistency?



##########
tests/system/providers/google/cloud/data_loss_prevention/example_dlp_info_types.py:
##########
@@ -64,12 +65,14 @@
 OBJECT_GCS_OUTPUT_URI = OBJECT_GCS_URI + FILE_NAME
 
 CUSTOM_INFO_TYPE_ID = "custom_info_type"
-CUSTOM_INFO_TYPES = {
-    "large_custom_dictionary": {
-        "output_path": {"path": OBJECT_GCS_OUTPUT_URI},
-        "cloud_storage_file_set": {"url": OBJECT_GCS_URI + "*"},
+CUSTOM_INFO_TYPES = StoredInfoTypeConfig(
+    {
+        "large_custom_dictionary": {
+            "output_path": {"path": OBJECT_GCS_OUTPUT_URI},
+            "cloud_storage_file_set": {"url": OBJECT_GCS_URI + "*"},

Review Comment:
   should we use f-string instead?
   ```suggestion
               "cloud_storage_file_set": {"url": f"{OBJECT_GCS_URI}*"},
   ```



##########
tests/system/providers/google/cloud/cloud_sql/example_cloud_sql_query_postgres.py:
##########
@@ -43,7 +43,7 @@
 from airflow.utils.trigger_rule import TriggerRule
 
 if TYPE_CHECKING:
-    from airflow.settings import Session
+    pass

Review Comment:
   same 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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382728100


##########
.pre-commit-config.yaml:
##########
@@ -1000,7 +1000,7 @@ repos:
         name: Run mypy for providers
         language: python
         entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
-        files: ^airflow/providers/.*\.py$|^tests/providers/\*\.py$|^tests/system/providers/\*\.py$
+        files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$

Review Comment:
   ```suggestion
           files: ^airflow/providers/.*\.py$|^tests/providers/.+\.py$|^tests/system/providers/.+\.py$
   ```
   
   Doesn’t really matter in practice but I don’t think we want to allow a file named exactly `.py`



##########
.pre-commit-config.yaml:
##########
@@ -1000,7 +1000,7 @@ repos:
         name: Run mypy for providers
         language: python
         entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
-        files: ^airflow/providers/.*\.py$|^tests/providers/\*\.py$|^tests/system/providers/\*\.py$
+        files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$

Review Comment:
   ```suggestion
           files: ^airflow/providers/.*\.py$|^tests/providers/.+\.py$|^tests/system/providers/.+\.py$
   ```
   
   Doesn’t really matter in practice but I don’t think we want to allow a file named exactly `.py`



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382897301


##########
tests/providers/amazon/aws/hooks/test_hooks_signature.py:
##########
@@ -187,10 +187,10 @@ def method2(self, spam: str):
     if not hooks:
         pytest.skip(reason=f"Module {hook_module!r} doesn't contain subclasses of `AwsGenericHook`.")
 
-    errors = []
+    errors: list[str] = []
     for hook, hook_name in hooks:
         is_valid, msg = validate_hook(hook, hook_name, hook_module)
-        if not is_valid:
+        if not is_valid and msg:
             errors.append(msg)

Review Comment:
   Why not :). We can even inline valudation_results it seems.



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #35465:
URL: https://github.com/apache/airflow/pull/35465#issuecomment-1793923538

   Huh...  We had not run mypy checks on `tests/providers` and `tests/system/providers` for quite a while it seems.


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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #35465:
URL: https://github.com/apache/airflow/pull/35465#discussion_r1382943021


##########
tests/system/providers/google/cloud/vertex_ai/example_vertex_ai_pipeline_job.py:
##########
@@ -17,7 +17,7 @@
 # under the License.
 
 # mypy ignore arg types (for templated fields)
-# type: ignore[arg-type]
+
 

Review Comment:
   I reviewed it and made consistent everywhere (removed old comment if not needed and explained where it is added to avoid missing default args warning. BTW. Good that we have those` # mypy: disable-error-codes` on a global level.



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


Re: [PR] Fix bad regexp in mypy-providers specification in pre-commits [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #35465:
URL: https://github.com/apache/airflow/pull/35465#issuecomment-1794334457

   Last round of reviews applied from @uranusjr and @Lee-W  - all the comments fixed.


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