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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
