Skip to content
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 #47275

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ repos:
files: ^airflow/models/taskinstance.py$|^airflow/models/taskinstancehistory.py$
pass_filenames: false
require_serial: true
- id: prevent-usage-of-session.query
name: Prevent usage of session.query
entry: ./scripts/ci/pre_commit/usage_session_query.py
language: python
additional_dependencies: ['rich>=12.4.4']
files: ^airflow.*\.py$|^task_sdk.*\.py
exclude: ^tests/.*\.py$|^task_sdk/tests/.*\.py$
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
exclude: ^tests/.*\.py$|^task_sdk/tests/.*\.py$

Since we have given it specific files to check, do we still need to exclude others?

pass_filenames: true
- id: check-deferrable-default
name: Check and fix default value of default_deferrable
language: python
Expand Down
2 changes: 2 additions & 0 deletions contributing-docs/08_static_code_checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ require Breeze Docker image to be built locally.
+-----------------------------------------------------------+--------------------------------------------------------+---------+
| pretty-format-json | Format JSON files | |
+-----------------------------------------------------------+--------------------------------------------------------+---------+
| prevent-usage-of-session.query | Prevent usage of session.query | |
+-----------------------------------------------------------+--------------------------------------------------------+---------+
| pylint | pylint | |
+-----------------------------------------------------------+--------------------------------------------------------+---------+
| python-no-log-warn | Check if there are no deprecate log warn | |
Expand Down
Loading
Loading