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

   Static checks fail intermittently with:
   
       OSError: [Errno 39] Directory not empty: 
'.../dev/breeze/src/airflow_breeze/utils/__pycache__'
   
   (example: 
https://github.com/apache/airflow/actions/runs/36368636328/job/108763434905)
   
   prek runs hooks in parallel, and every breeze invocation removes all 
`__pycache__` directories
   in the checkout on start-up. Any other hook process importing from the 
source tree — breeze
   itself, prek hook scripts, local mypy runs — can write a fresh `.pyc` 
between `rmtree`
   emptying a directory and removing it, which fails the breeze-based hook.
   
   - Every prek hook (all configs, including meta and remote-repo hooks) now 
sets
     `PYTHONPYCACHEPREFIX: .build/pycache`, so hooks no longer write bytecode 
next to the sources
     while other hooks are cleaning them. `.build/` is gitignored and skipped 
by breeze's cleanup
     walk. prek has no top-level `env:`, hence the per-hook setting. `.pyc` 
names carry the
     interpreter tag, so hooks on different Python versions can share the 
prefix safely.
   - New `check-prek-hooks-pycache-prefix` hook fails when a hook is missing 
the setting, so new
     hooks cannot reintroduce the race; the `check-shared-mypy-hooks` template 
includes it too.
   - `cleanup_python_generated_files` additionally tolerates `ENOTEMPTY`, for 
writers prek does not
     control (e.g. an IDE compiling while breeze cleans up).
   
   Tested locally: new unit tests for the cleanup and the checker (each fails 
without the change),
   `prek validate-config` on all configs, the pre-commit stage on the change, 
and a check that a
   hook run leaves no `__pycache__` in `scripts/ci/prek/` but writes to 
`.build/pycache`.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Claude Opus 5)
   
   Generated-by: Claude Code (Claude Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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