Skip to content

Conversation

@justinpakzad
Copy link
Contributor

closes: #59896

Made SQLAlchemy an optional dependency for the Amazon provider. The imports are now wrapped with try/except and AirflowOptionalProviderFeatureException() gets raised if it is not installed.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

@boring-cyborg boring-cyborg bot added area:providers provider:amazon AWS/Amazon - related issues labels Dec 30, 2025
@potiuk potiuk merged commit c680d8e into apache:main Jan 4, 2026
101 checks passed
try:
from sqlalchemy.engine.url import URL
except ImportError:
URL = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@potiuk Please note before approving similar PRs that leaving URL untyped (i.e. URL: Any before the try block) or unignored (# type: ignore[assignment,misc]) leads to mypy violations on SQLA2:

providers/amazon/src/airflow/providers/amazon/aws/hooks/redshift_sql.py:30: error: Cannot assign to a type  [misc]
        URL = create_engine = None
        ^~~
providers/amazon/src/airflow/providers/amazon/aws/hooks/redshift_sql.py:30: error: Incompatible types in assignment (expression has
type "None", variable has type "type[URL]")  [assignment]
        URL = create_engine = None
        ^
providers/amazon/src/airflow/providers/amazon/aws/hooks/redshift_sql.py:30: error: Incompatible types in assignment (expression has
type "None", variable has type overloaded function)  [assignment]
        URL = create_engine = None
                              ^~~~
providers/amazon/src/airflow/providers/amazon/aws/hooks/athena_sql.py:28: error: Cannot assign to a type  [misc]
        URL = None
        ^~~
providers/amazon/src/airflow/providers/amazon/aws/hooks/athena_sql.py:28: error: Incompatible types in assignment (expression has type
"None", variable has type "type[URL]")  [assignment]
        URL = None
              ^~~~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. That's unfortunate indeed

chirodip98 pushed a commit to chirodip98/airflow-contrib that referenced this pull request Jan 5, 2026
* Made sqlalchemy dependency  optional for amazon provider

* Prek formatting
chirodip98 pushed a commit to chirodip98/airflow-contrib that referenced this pull request Jan 8, 2026
* Made sqlalchemy dependency  optional for amazon provider

* Prek formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add proper dependencies for sqlalchemy - amazon

3 participants