ashb commented on code in PR #65513:
URL: https://github.com/apache/airflow/pull/65513#discussion_r3141849744
##########
providers/celery/src/airflow/providers/celery/cli/celery_command.py:
##########
@@ -31,16 +31,26 @@
from celery.app.defaults import DEFAULT_TASK_LOG_FMT
from celery.app.log import TaskFormatter
from celery.signals import after_setup_logger
-from lockfile.pidlockfile import read_pid_from_pidfile, remove_existing_pidfile
from airflow import settings
from airflow.cli.simple_table import AirflowConsole
from airflow.exceptions import AirflowConfigException
-from airflow.providers.celery.version_compat import AIRFLOW_V_3_0_PLUS,
AIRFLOW_V_3_2_PLUS
+from airflow.providers.celery.version_compat import (
+ AIRFLOW_V_3_0_PLUS,
+ AIRFLOW_V_3_2_2_PLUS,
+ AIRFLOW_V_3_2_PLUS,
+)
from airflow.providers.common.compat.sdk import conf
from airflow.utils import cli as cli_utils
from airflow.utils.cli import setup_locations
+if AIRFLOW_V_3_2_2_PLUS:
+ # Airflow 3.2.2 has dropped dependency to lockfile and vendored-in the
package
+ from airflow.utils.pidfile import read_pid_from_pidfile,
remove_existing_pidfile
+else:
+ # For Airflow versions < 3.2.2, we need to import from lockfile package
+ from lockfile.pidlockfile import read_pid_from_pidfile,
remove_existing_pidfile # type: ignore
Review Comment:
I really think htis case is better served by a `try/except ImportError`.
```suggestion
try:
# Airflow 3.2.2 has dropped dependency to lockfile and vendored-in the
package
from airflow.utils.pidfile import read_pid_from_pidfile,
remove_existing_pidfile
except ImportError:
# For Airflow versions < 3.2.2, we need to import from lockfile package
from lockfile.pidlockfile import read_pid_from_pidfile,
remove_existing_pidfile # type: ignore
```
--
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]