potiuk commented on PR #77463:
URL: https://github.com/apache/airflow/pull/77463#issuecomment-7133898984

   On your two questions:
   
   **Should `patch` / `patch.object` count?** Yes. `AGENTS.md` says "Use 
`spec`/`autospec` when mocking", and a `patch()` without `autospec` creates the 
same unspecced `MagicMock`. If they don't count, two thirds of the cases stay 
unchecked. Some calls are fine without `autospec`, though, because they don't 
create an unspecced mock: `new=<real object>` and `new_callable=` (which picks 
the class). `autospec` also doesn't work everywhere: instance attributes set in 
`__init__` and some properties need `new=` or `spec_set`. So please count 
`new=` (except `new=mock.DEFAULT`), `new_callable=` and `spec_set=` as specced, 
and test those cases.
   
   **Block from the start or manual stage first?** Block from the start. The 
allowlist already grandfathers the 28,578 existing cases, so a blocking hook 
only stops new ones. In the manual stage nobody runs it, so the allowlist is 
never tightened and the counts drift. You already measured that: 35 of the last 
200 commits add one. Before it blocks, please fix the issues from my review: 
the allowlist location, the `SyntaxError` handling, `spec=None`, and 
`require_serial`. Also, the static checks job in your fork CI is red, so please 
check whether this hook is the cause.
   
   ---
   _Drafted with an AI-assisted tool and reviewed by me before posting._
   


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