SEPURI-SAI-KRISHNA opened a new pull request, #73681:
URL: https://github.com/apache/airflow/pull/73681

   Follow-up to #72171, where moving the static half of this check out of the 
test suite was agreed in review.
   
   The check has two halves. One is a pure static sweep over the amazon 
provider: every `self.defer(trigger=...)` must hand `region_name`, `verify` and 
`botocore_config` to the trigger, and every hook a trigger module builds by 
hand must carry the same configuration. That half never needed the classes, 
only the source, but it lived in a unit test, so it only ran where the provider 
and its optional peers were installed, and a missing optional dependency turned 
it into a collection error rather than a result.
   
   It is now `scripts/ci/prek/check_deferred_hook_configuration.py`, modelled 
on the existing `check_trigger_serialize_init.py` and registered in 
`providers/.pre-commit-config.yaml`. It imports nothing from airflow, so it 
reports at commit time on any checkout.
   
   The other half, that the hook class a trigger names accepts what 
`_hook_parameters` will pass it, does need the classes, so it stays a test. Its 
module walk now skips a trigger module whose optional dependency is absent 
instead of failing collection, which is the case `triggers/eks.py` hits when 
amazon is installed without cncf.kubernetes.
   
   Two smaller things came out of the same review. The hand-built hook 
exceptions are now keyed by path relative to the aws package rather than by 
bare filename, so two trigger modules sharing a name cannot share an entry. The 
finder functions now take the root to scan as an argument, which is what makes 
them testable at all.
   
   The allowlists keep the property that made them useful: they are checked in 
both directions, so an entry that is no longer needed fails the check and has 
to be removed.
   
   **How this was verified**
   
   The new hook and the test it replaces were run against the same tree and 
produce identical results: 116 defer sites, 47 hand-built hook constructions, 
and the same single unreadable site. The port changes no verdict. It takes 
1.08s over the 276 files in the provider.
   
   `scripts/tests/ci/prek/test_check_deferred_hook_configuration.py` covers the 
finders, the error messages and both allowlist expiries, 26 tests. Each was 
checked against a deliberately broken hook: keying on basename, dropping either 
allowlist expiry, reinstating the old directory filter, returning an empty list 
instead of `None` for an unresolvable expression, dropping the stale-entry 
report, and letting an unparseable module pass silently or crash are all caught.
   
   Also run: the trimmed provider test (42 passed, 32 skipped), 
`scripts/tests/ci` plus the docker and react-plugin tests (1433 passed, 1 
pre-existing failure that needs a working breeze), the amazon unit suite (4925 
passed, with this environment's usual `airflow_shared` and paramiko gaps), mypy 
on all three files, and prek over every changed file (261 hooks, no failures).
   
   The two `triggers/eks.py` cleanups also mentioned in that review are 
deliberately not here, so this stays a tooling change with no provider 
behaviour in it.
   
   related: #72171
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes - Claude Code (Opus 5)
   


-- 
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]

Reply via email to