-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pre-commit To Prevent Usage of session.query In Core Airflow #45714
base: main
Are you sure you want to change the base?
Add pre-commit To Prevent Usage of session.query In Core Airflow #45714
Conversation
a conflict occurred with the images, and I'm not sure how to resolve it. Would you please help me? |
as explained in slack - you can replace the confilcting images / .txt with either versions, rebase and re-run pre-commit. The images wil get regenerated to be "latest" automatically (in fact it should happen automatically when you rebase your PR and resolve the conflicts if you did |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prove that this works would be that it detects all the session.query usages in Airflow core and we have to fix it.
if file_path.name.startswith("test_"): | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check for tests file is not necessary because you have the files to look for at the pre-commit-config.yaml entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
and isinstance(node.func.value, ast.Name) | ||
and node.func.value.id == "session" | ||
): | ||
console.print(f"Remove session.query from line {node.lineno}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are removing the session.query because it is deprecated in SQLAlchemy 2. The message should reflect this and suggest that the user use the new-style query constructs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done !
I tried to write msg from session.query
IS it okay ?
433f780
to
f5d0a67
Compare
Could you please clarify it for me? |
closes : #45461
Introduce a pre-commit hook to prevent the use of
session.query
in the core Airflow code.This is limited to the source code and excludes the tests/ package.
^ 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 newsfragments.