Skip to content

Consolidate AllowlistManager for prek hooks#69327

Draft
jason810496 wants to merge 2 commits into
apache:mainfrom
jason810496:refactor/ci/consolidate-allow-list-manager
Draft

Consolidate AllowlistManager for prek hooks#69327
jason810496 wants to merge 2 commits into
apache:mainfrom
jason810496:refactor/ci/consolidate-allow-list-manager

Conversation

@jason810496

Copy link
Copy Markdown
Member

Why

  • The AllowlistManager is the common pattern now, we should introduce a common interface the common_prek module so that the further use case can reuse them without duplicating the whole AllowlistManager one.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Fable 5)

Generated-by: Claude Code (Fable 5) following the guidelines

@jason810496 jason810496 changed the title CI: Consolidate AllowlistManager CI: Consolidate AllowlistManager for prek hooks Jul 3, 2026
@jason810496 jason810496 changed the title CI: Consolidate AllowlistManager for prek hooks Consolidate AllowlistManager for prek hooks Jul 3, 2026
@jason810496 jason810496 removed the backport-to-v3-3-test Backport to v3-3-test label Jul 3, 2026
@jason810496 jason810496 self-assigned this Jul 3, 2026
The allowlist load/save/generate/cleanup logic was duplicated across
check_new_airflow_exception_usage.py and check_provide_session_kwargs.py.
This consolidates the shared pattern into an abstract AllowListManager
in common_prek_utils.py, with subclasses providing only iter_files()
and count_occurrences().
The initial extraction left the scan/tighten/report loop duplicated
in both hook scripts and exposed `parse` as a staticmethod that
silently ignored the instance's `repo_root`.

- Convert `parse` from `@staticmethod` to instance method so it
  always uses `self.repo_root` (fixes the latent footgun where
  `_parse_tracked_allowlist` called parse unbound).
- Hoist the check loop into `AllowlistManager.check()` with
  `violation_panel_text()` (abstract) and `format_violation_details()`
  (overridable) hooks — both `_check_*` wrappers are now one-liners.
- Fix naming: `AllowListManager` → `AllowlistManager` to match the
  subclass convention used throughout.
- Add test coverage for `check_new_airflow_exception_usage.py`.
@jason810496 jason810496 force-pushed the refactor/ci/consolidate-allow-list-manager branch from 80d27d2 to 59907b5 Compare July 3, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant