You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Dev-iL (via GitHub)" <gi...@apache.org> on 2025/07/27 09:55:39 UTC

[PR] Fix several deprecation warnings related to airflow.sdk [airflow]

Dev-iL opened a new pull request, #53791:
URL: https://github.com/apache/airflow/pull/53791

   <!--
    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/
   -->
   Fixing some deprecations reported by breeze:
   ```none
   {"category": "DeprecationWarning", "message": "The `airflow.models.baseoperator.BaseOperator` attribute is deprecated. Please use `'airflow.sdk.bases.operator.BaseOperator'`.", "filename": "devel-common/src/tests_common/test_utils/mock_operators.py", "lineno": 24, "when": "collect", "node_id": null, "param_id": null, "group": "other", "count": 1}
   {"category": "DeprecationWarning", "message": "The `airflow.models.baseoperator.BaseOperator` attribute is deprecated. Please use `'airflow.sdk.bases.operator.BaseOperator'`.", "filename": "airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py", "lineno": 37, "when": "collect", "node_id": null, "param_id": null, "group": "tests", "count": 1}
   {"category": "DeprecationWarning", "message": "The `airflow.models.baseoperator.BaseOperator` attribute is deprecated. Please use `'airflow.sdk.bases.operator.BaseOperator'`.", "filename": "devel-common/src/tests_common/test_utils/mock_operators.py", "lineno": 24, "when": "runtest", "node_id": "airflow-core/tests/unit/callbacks/test_callback_requests.py::TestCallbackRequest::test_from_json", "param_id": "None-TaskCallbackRequest", "group": "other", "count": 1}
   {"category": "DeprecationWarning", "message": "The `airflow.utils.timezone.coerce_datetime` attribute is deprecated. Please use `'airflow.sdk.timezone.coerce_datetime'`.", "filename": "providers/standard/src/airflow/providers/standard/sensors/time.py", "lineno": 93, "when": "runtest", "node_id": "airflow-core/tests/unit/callbacks/test_callback_requests.py::TestCallbackRequest::test_from_json", "param_id": "None-TaskCallbackRequest", "group": "providers", "count": 4}
   {"category": "DeprecationWarning", "message": "The `airflow.utils.timezone.convert_to_utc` attribute is deprecated. Please use `'airflow.sdk.timezone.convert_to_utc'`.", "filename": "providers/standard/src/airflow/providers/standard/sensors/time.py", "lineno": 100, "when": "runtest", "node_id": "airflow-core/tests/unit/callbacks/test_callback_requests.py::TestCallbackRequest::test_from_json", "param_id": "None-TaskCallbackRequest", "group": "providers", "count": 4}
   {"category": "DeprecationWarning", "message": "The `airflow.utils.timezone.datetime` attribute is deprecated. Please use `'airflow.sdk.timezone.datetime'`.", "filename": "airflow-core/src/airflow/example_dags/standard/example_external_task_parent_deferrable.py", "lineno": 23, "when": "runtest", "node_id": "airflow-core/tests/unit/callbacks/test_callback_requests.py::TestCallbackRequest::test_from_json", "param_id": "None-TaskCallbackRequest", "group": "other", "count": 1}
   {"category": "DeprecationWarning", "message": "The `airflow.models.baseoperator.BaseOperator` attribute is deprecated. Please use `'airflow.sdk.bases.operator.BaseOperator'`.", "filename": "providers/standard/src/airflow/providers/standard/operators/hitl.py", "lineno": 32, "when": "runtest", "node_id": "airflow-core/tests/unit/callbacks/test_callback_requests.py::TestCallbackRequest::test_from_json", "param_id": "None-TaskCallbackRequest", "group": "providers", "count": 1}
   ```
   CC: @amoghrajesh 
   <!-- 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-docs/05_pull_requests.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 [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -55,8 +54,14 @@
     clear_db_runs,
     parse_and_sync_to_db,
 )
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS

Review Comment:
   [nitpick] The version compatibility import should be placed with other imports at the top of the file rather than in the middle of the import section for better code organization.



##########
devel-common/src/tests_common/test_utils/mock_operators.py:
##########
@@ -21,10 +21,8 @@
 
 import attr
 
-from airflow.models.baseoperator import BaseOperator
-
 from tests_common.test_utils.compat import BaseOperatorLink
-from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS, AIRFLOW_V_3_1_PLUS

Review Comment:
   The import of AIRFLOW_V_3_0_PLUS is no longer used after removing the original import check. Consider removing it to keep imports clean.



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
providers/standard/tests/unit/standard/sensors/test_time_delta.py:
##########
@@ -34,12 +34,17 @@
     WaitSensor,
 )
 from airflow.providers.standard.triggers.temporal import DateTimeTrigger
-from airflow.utils import timezone
-from airflow.utils.timezone import datetime
 from airflow.utils.types import DagRunType
 
 from tests_common.test_utils import db
-from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS, AIRFLOW_V_3_1_PLUS
+
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk import timezone
+    from airflow.sdk.timezone import datetime
+else:
+    from airflow.utils import timezone  # type: ignore[no-redef]
+    from airflow.utils.timezone import datetime  # type: ignore[no-redef]

Review Comment:
   Same comment as above.
   Can merge the imports into one too



##########
providers/standard/tests/unit/standard/sensors/test_weekday.py:
##########
@@ -26,11 +26,16 @@
 from airflow.models.dag import DAG
 from airflow.providers.standard.sensors.weekday import DayOfWeekSensor
 from airflow.providers.standard.utils.weekday import WeekDay
-from airflow.utils import timezone
-from airflow.utils.timezone import datetime
 
 from tests_common.test_utils import db
-from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS, AIRFLOW_V_3_1_PLUS
+
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk import timezone
+    from airflow.sdk.timezone import datetime
+else:
+    from airflow.utils import timezone  # type: ignore[no-redef]
+    from airflow.utils.timezone import datetime  # type: ignore[no-redef]

Review Comment:
   Same comment as above



##########
providers/standard/tests/unit/standard/sensors/test_date_time.py:
##########
@@ -25,7 +25,13 @@
 from airflow import macros
 from airflow.models.dag import DAG
 from airflow.providers.standard.sensors.date_time import DateTimeSensor
-from airflow.utils import timezone
+
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
+
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk import timezone
+else:
+    from airflow.utils import timezone  # type: ignore[no-redef]

Review Comment:
   try / except here too please



##########
providers/standard/tests/unit/standard/sensors/test_python.py:
##########
@@ -24,10 +24,15 @@
 
 from airflow.exceptions import AirflowSensorTimeout
 from airflow.providers.standard.sensors.python import PythonSensor
-from airflow.sensors.base import PokeReturnValue
 
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.standard.operators.test_python import BasePythonTest
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.sensor import PokeReturnValue
+else:
+    from airflow.sensors.base import PokeReturnValue  # type: ignore[no-redef]

Review Comment:
   You could just add this in version_compat.py and import them like:
   ```
   from tests_common.test_utils.version_compat import PokeReturnValue
   ```



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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

   Fixed 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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2240341867


##########
providers/standard/src/airflow/providers/standard/operators/hitl.py:
##########
@@ -29,10 +29,10 @@
 from datetime import datetime, timezone
 from typing import TYPE_CHECKING, Any
 
-from airflow.models.baseoperator import BaseOperator
 from airflow.providers.standard.exceptions import HITLTimeoutError, HITLTriggerEventError
 from airflow.providers.standard.triggers.hitl import HITLTrigger, HITLTriggerEventSuccessPayload
 from airflow.providers.standard.utils.skipmixin import SkipMixin
+from airflow.sdk.bases.operator import BaseOperator

Review Comment:
   It is for 3.1 only, see a few lines above:
   ```python
   if not AIRFLOW_V_3_1_PLUS:
       raise AirflowOptionalProviderFeatureException("Human in the loop functionality needs Airflow 3.1+.")
   ```
   
   This was changed to the below anyway
   ```python
   from airflow.providers.standard.version_compat import BaseOperator
   ```



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2233892181


##########
devel-common/src/tests_common/test_utils/mock_operators.py:
##########
@@ -21,10 +21,8 @@
 
 import attr
 
-from airflow.models.baseoperator import BaseOperator
-
 from tests_common.test_utils.compat import BaseOperatorLink
-from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS, AIRFLOW_V_3_1_PLUS

Review Comment:
   Resolving because wrong.



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2240344270


##########
providers/standard/src/airflow/providers/standard/sensors/time.py:
##########
@@ -42,7 +42,10 @@ class StartTriggerArgs:  # type: ignore[no-redef]
         timeout: datetime.timedelta | None = None
 
 
-from airflow.utils import timezone
+try:
+    from airflow.sdk import timezone

Review Comment:
   Why should I be accessing a protected member of the module? Are you worried about circular imports? Finally - if it's wrong, how come none of the tests failed?



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2233892570


##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -55,8 +54,14 @@
     clear_db_runs,
     parse_and_sync_to_db,
 )
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS

Review Comment:
   Pretty sure this comment is wrong



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -55,8 +54,14 @@
     clear_db_runs,
     parse_and_sync_to_db,
 )
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.models import TEST_DAGS_FOLDER
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.operator import BaseOperator

Review Comment:
   ```suggestion
       from airflow.sdk import BaseOperator
   ```
   
   As a rule of thumb, `airflow.sdk` is the public interface of the sdk and should be used instead of modules inside whenever possible.



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -55,8 +54,14 @@
     clear_db_runs,
     parse_and_sync_to_db,
 )
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.models import TEST_DAGS_FOLDER
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.operator import BaseOperator

Review Comment:
   Also should this be 3.0+ 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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
providers/standard/tests/unit/standard/sensors/test_python.py:
##########
@@ -24,10 +24,15 @@
 
 from airflow.exceptions import AirflowSensorTimeout
 from airflow.providers.standard.sensors.python import PythonSensor
-from airflow.sensors.base import PokeReturnValue
 
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.standard.operators.test_python import BasePythonTest
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.sensor import PokeReturnValue
+else:
+    from airflow.sensors.base import PokeReturnValue  # type: ignore[no-redef]

Review Comment:
   I almost never recommend if / else anymore (might have done in the past but not anymore).
   
   We have a couple of those occurrences in the repo which need cleanup, but trying to not introduce new ones. Because we compat here it between sdk / providers, not core. The `AIRFLOW_V_x_y_PLUS` checks compatibility based on version of airflow core which semantically isn't correct even, so while we can, better to have try / except (more robust too)



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
devel-common/src/tests_common/test_utils/mock_operators.py:
##########
@@ -34,6 +32,11 @@
 else:
     from airflow.models.xcom import XCom  # type: ignore[no-redef]
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.operator import BaseOperator
+else:
+    from airflow.models.baseoperator import BaseOperator  # type: ignore[no-redef]

Review Comment:
   Same here, let's use try / except.



##########
providers/standard/src/airflow/providers/standard/operators/hitl.py:
##########
@@ -29,10 +29,10 @@
 from datetime import datetime, timezone
 from typing import TYPE_CHECKING, Any
 
-from airflow.models.baseoperator import BaseOperator
 from airflow.providers.standard.exceptions import HITLTimeoutError, HITLTriggerEventError
 from airflow.providers.standard.triggers.hitl import HITLTrigger, HITLTriggerEventSuccessPayload
 from airflow.providers.standard.utils.skipmixin import SkipMixin
+from airflow.sdk.bases.operator import BaseOperator

Review Comment:
   This could break compat, you should add it with a try / except here.
   
   Unless the operator is only supposed to work for 3.1+ 
   
   cc @Lee-W 



##########
providers/standard/src/airflow/providers/standard/sensors/time.py:
##########
@@ -42,7 +42,10 @@ class StartTriggerArgs:  # type: ignore[no-redef]
         timeout: datetime.timedelta | None = None
 
 
-from airflow.utils import timezone
+try:
+    from airflow.sdk import timezone

Review Comment:
   This isn't right, you should be using:
   ```
   from airflow.sdk._shared.timezones import timezone
   ```



##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -55,8 +54,14 @@
     clear_db_runs,
     parse_and_sync_to_db,
 )
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.models import TEST_DAGS_FOLDER
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.operator import BaseOperator
+else:
+    from airflow.models.baseoperator import BaseOperator  # type: ignore[no-redef]

Review Comment:
   I'd rather use try / except actually.



##########
airflow-core/tests/unit/cli/commands/test_dag_command.py:
##########
@@ -55,8 +54,14 @@
     clear_db_runs,
     parse_and_sync_to_db,
 )
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.models import TEST_DAGS_FOLDER
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.operator import BaseOperator
+else:
+    from airflow.models.baseoperator import BaseOperator  # type: ignore[no-redef]

Review Comment:
   Semantically, we could use v_3_0 here because the move for BaseOperator to sdk was done in that timeframe (not that it will affect the functionality here)



##########
pyproject.toml:
##########
@@ -754,6 +754,7 @@ testing = ["dev", "providers.tests", "tests_common", "tests", "system", "unit",
 "kubernetes-tests/*" = ["D", "TID253", "S101", "TRY002"]
 "helm-tests/*" = ["D", "TID253", "S101", "TRY002"]
 "providers/**/tests/*" = ["D", "TID253", "S101", "TRY002"]
+"performance/tests/*" = ["S101"]

Review Comment:
   Why this change? Did you encounter the flake8-bandit’s S101 rule?



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2243364222


##########
providers/standard/tests/unit/standard/sensors/test_python.py:
##########
@@ -24,10 +24,15 @@
 
 from airflow.exceptions import AirflowSensorTimeout
 from airflow.providers.standard.sensors.python import PythonSensor
-from airflow.sensors.base import PokeReturnValue
 
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.standard.operators.test_python import BasePythonTest
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.sensor import PokeReturnValue
+else:
+    from airflow.sensors.base import PokeReturnValue  # type: ignore[no-redef]

Review Comment:
   When do you recommend try/except and when a conditional import?



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2240348552


##########
pyproject.toml:
##########
@@ -754,6 +754,7 @@ testing = ["dev", "providers.tests", "tests_common", "tests", "system", "unit",
 "kubernetes-tests/*" = ["D", "TID253", "S101", "TRY002"]
 "helm-tests/*" = ["D", "TID253", "S101", "TRY002"]
 "providers/**/tests/*" = ["D", "TID253", "S101", "TRY002"]
+"performance/tests/*" = ["S101"]

Review Comment:
   When I ran `ruff check .` in the repo root it showed a bunch of violations under that path. I figured I might as well fix that too.



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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


-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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

   There are some errors though :( 


-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2240344270


##########
providers/standard/src/airflow/providers/standard/sensors/time.py:
##########
@@ -42,7 +42,10 @@ class StartTriggerArgs:  # type: ignore[no-redef]
         timeout: datetime.timedelta | None = None
 
 
-from airflow.utils import timezone
+try:
+    from airflow.sdk import timezone

Review Comment:
   Why should I be accessing a protected member of the module?



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

Posted by "Dev-iL (via GitHub)" <gi...@apache.org>.
Dev-iL commented on code in PR #53791:
URL: https://github.com/apache/airflow/pull/53791#discussion_r2243364222


##########
providers/standard/tests/unit/standard/sensors/test_python.py:
##########
@@ -24,10 +24,15 @@
 
 from airflow.exceptions import AirflowSensorTimeout
 from airflow.providers.standard.sensors.python import PythonSensor
-from airflow.sensors.base import PokeReturnValue
 
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS
 from unit.standard.operators.test_python import BasePythonTest
 
+if AIRFLOW_V_3_1_PLUS:
+    from airflow.sdk.bases.sensor import PokeReturnValue
+else:
+    from airflow.sensors.base import PokeReturnValue  # type: ignore[no-redef]

Review Comment:
   When do you recommend try/except and when conditioal import?



-- 
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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
providers/standard/src/airflow/providers/standard/sensors/time.py:
##########
@@ -42,7 +42,10 @@ class StartTriggerArgs:  # type: ignore[no-redef]
         timeout: datetime.timedelta | None = None
 
 
-from airflow.utils import timezone
+try:
+    from airflow.sdk import timezone

Review Comment:
   It's not a protected member per say but part of the shared library / common code that is shared across distros of Airflow. It was added as part of #53149.
   
   That said, I thought this was sdk file that was changed but its a provider which is intended to be a consumer of the sdk, therefore the import is correct. The airflow.sdk.timezone module is a re-export layer of ` airflow.sdk._shared.timezones`, so it is alright. Correcting myself, all good 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 several deprecation warnings related to airflow.sdk [airflow]

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


##########
providers/standard/src/airflow/providers/standard/operators/hitl.py:
##########
@@ -29,10 +29,10 @@
 from datetime import datetime, timezone
 from typing import TYPE_CHECKING, Any
 
-from airflow.models.baseoperator import BaseOperator
 from airflow.providers.standard.exceptions import HITLTimeoutError, HITLTriggerEventError
 from airflow.providers.standard.triggers.hitl import HITLTrigger, HITLTriggerEventSuccessPayload
 from airflow.providers.standard.utils.skipmixin import SkipMixin
+from airflow.sdk.bases.operator import BaseOperator

Review Comment:
   Yeah checked with Wei too, sounds good.



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