fix: migrate deprecated imports to SDK equivalents (airflow-ai)#67623
fix: migrate deprecated imports to SDK equivalents (airflow-ai)#67623yugmerabtene wants to merge 2 commits into
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
Applied 312 import path corrections across 275 files: - airflow.utils.state -> airflow.sdk.state - airflow.utils.helpers -> airflow.sdk.utils.helpers - airflow.utils.log -> airflow.sdk.utils.log - airflow.exceptions.AirflowException -> airflow.sdk.exceptions.AirflowException - airflow.utils.timezone -> pendulum Generated by airflow-fix (github.com/yugmerabtene/airflow-fix)
| ) | ||
| from airflow.providers.common.compat.sdk import AirflowException | ||
| from airflow.utils.timezone import datetime | ||
| import pendulum # replaces airflow.utils.timezone datetime |
There was a problem hiding this comment.
Wouldn't that break lines 377 and 378?
Wouldn't it be necessary to update them to
pendulum.datetime(...)or use the time zone present in the SDK?
| from airflow.utils.state import State | ||
| from airflow.utils.timezone import datetime | ||
| from airflow.sdk.state import State | ||
| import pendulum # replaces airflow.utils.timezone datetime |
There was a problem hiding this comment.
Same here, I believe this would imply all lines that are using datetime.
The original fix replaced 'from airflow.utils.timezone import datetime'
with 'import pendulum', but this broke existing datetime(...) calls
since they would now resolve to the stdlib datetime class instead of
pendulum's timezone-aware datetime function.
The correct fix is 'from pendulum import datetime', which preserves
all existing datetime(...) call sites.
Also fixed utcnow() -> pendulum.now('UTC'),
convert_to_utc() -> pendulum.instance(x).in_timezone('UTC'),
coerce_datetime -> pendulum.instance
where applicable.
|
Good catch @Pedrinhonitz — broke existing call sites since they resolved to stdlib datetime instead of pendulum's timezone-aware version. Fixed across all 36 affected files:
Updated in commit 6e61409 on the same branch. |
| from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook | ||
| from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator | ||
| from airflow.utils.helpers import prune_dict | ||
| from airflow.sdk.utils.helpers import prune_dict |
There was a problem hiding this comment.
Airflow Providers still support Airflow 2.0 so we can't just change to airflow.sdk
kaxil
left a comment
There was a problem hiding this comment.
Airflow Providers still support Airflow 2.0 so we can't just change to airflow.sdk
Description
This PR migrates deprecated import paths to their SDK equivalents across the codebase. Generated by airflow-ai, an AI-powered toolkit for Airflow maintenance.
Changes
312 import path corrections across 275 files:
airflow.utils.state→airflow.sdk.stateairflow.utils.helpers→airflow.sdk.utils.helpersairflow.exceptions.AirflowException→airflow.sdk.exceptions.AirflowExceptionairflow.utils.log→airflow.sdk.utils.logairflow.utils.timezone→pendulumVerification
airflow.utils.log.*) left intact — SDK equivalents don't exist yetNotes