Andrushika opened a new pull request, #77463:
URL: https://github.com/apache/airflow/pull/77463

   ## Why
   
   Airflow tests must give every mock a `spec` or `autospec`. The rule is in 
`AGENTS.md` and in the review instructions under `.github/instructions/`.
   
   A mock without a spec accepts any attribute and any call. A test can then 
pass against a method that does not exist.
   
   No check enforces the rule, so reviewers ask for it by hand (#73221, #77073, 
#76908).
   
   ## What
   
   Add the `check-no-new-unspecced-mocks` prek hook. It counts mock class calls 
such as `MagicMock()`, and `patch` or `patch.object` calls, that have no spec 
in test files.
   
   The 28,578 existing ones in 1,344 files go into 
`generated/known_unspecced_mocks.txt`. The allowlist works like the one for 
`check-no-new-airflow-exceptions`. A file fails when its count goes up, and its 
entry goes down when the count drops.
   
   In the last 200 commits on main, 35 add at least one mock without a spec. In 
39 of them the counts change, so I will regenerate the allowlist on the final 
rebase.
   
   Two things I'm not sure about:
   
   - `patch` and `patch.object` without `autospec` are about two thirds of the 
existing ones. Should they count too, or only the mock classes that the review 
instructions name?
   - Should the hook block from the start, or run in the manual stage first?
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 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]

Reply via email to