potiuk opened a new pull request, #65880:
URL: https://github.com/apache/airflow/pull/65880
Extracts the parts of #65621 that pass on current main into the existing
`check-shared-distributions-structure` prek hook, so we can land the
boundary-checking infrastructure now without waiting for the residual
import cleanups it surfaces.
## What's added
Four AST-based checks, all gated to skip imports nested in
`if TYPE_CHECKING:` blocks:
1. **Shared distributions must not depend on `apache-airflow*`** —
covers regular, optional, and PEP 735 dependency-groups.
2. **Shared distributions must not import from `airflow.*`** in
`src/` or `tests/`. Error message includes the standard
relative-import / move-to-another-distribution fix guidance.
3. **`task-sdk` and `airflow-core` must not import from the
`airflow_shared` namespace** — that namespace is the
consumer-facing PyPI shape; in-monorepo code uses the
`airflow.sdk._shared.*` / `airflow._shared.*` symlinks.
4. **`task-sdk` may only import `_shared` through
`airflow.sdk._shared.*`** (not `airflow._shared.*`). Caught one
residual offender (`task-sdk/.../deadline.py`); fixed in this PR.
The equivalent allowed-prefix check for `airflow-core` is
intentionally deferred — `airflow-core` still imports
`SecretsMasker` and a couple of friends from `airflow.sdk._shared`,
and that requires a code move before the check can be turned on.
That part stays in #65621 to land once the imports are relocated.
Also bundled (small, related):
- Expanded the hook's file filter so it fires for changes under
`airflow-core/`, `task-sdk/`, `_shared/` and any `pyproject.toml` —
not only files under `shared/`.
- Added `scripts/ci/prek` to breeze's `FULL_TESTS_NEEDED_FILES`
(and flipped the test that asserted otherwise) so prek-hook
changes trigger the full test matrix.
## Test plan
- [X] \`prek run check-shared-distributions-structure --all-files\` passes
- [X] \`pytest
dev/breeze/tests/test_selective_checks.py::test_full_test_needed_when_scripts_changes\`
passes
- [ ] CI
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 4.7)
Generated-by: Claude Code (Opus 4.7) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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]