shivaam opened a new pull request, #71589: URL: https://github.com/apache/airflow/pull/71589
Unit tests currently contain setup-time `clear_db_*` calls that can hide state leaked by the previous test or missing fixture ownership. The existing debt is broad enough that removing it safely requires several independently reviewable changes. This PR establishes the first guardrail for that work: - add an AST-based prek check for setup-time database pre-cleaning in xUnit setup methods, pytest fixture setup paths, and direct test-body prefixes; - distinguish setup from teardown across fixture control flow; - record the current debt as a generated, shrinking `path::count` baseline; - fail when a file is added to the baseline or an existing count grows, while allowing cleanup work to reduce it; - cover import aliases, fixture and xUnit classification, exceptional control flow, baseline validation, and CI comparison behavior with focused tests. The baseline records 328 setup-time cleanup calls across 86 unit-test files. This PR does not remove those calls or change Airflow runtime behavior; it prevents the debt from growing while follow-up PRs move cleanup into owning fixtures. Related: #71577 Validation: - 195 focused and neighboring script tests passed - checker passed twice across all files and against the pre-change revision - registered hook and `check-hooks-apply` passed - Ruff, Ruff formatting, and `mypy-scripts` passed - real Airflow daemon and full dev-mode UI smoke checks passed at the reviewed revision No user-facing behavior or dependency changes are included, so no newsfragment is needed. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — OpenAI Codex Generated-by: [OpenAI Codex](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) --- * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. -- 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]
