Skip to content

Preserve prefix-sharing siblings when excluding directories - #1341

Open
vinsymoyya wants to merge 1 commit into
google:mainfrom
vinsymoyya:fix/excluded-directory-prefix
Open

vinsymoyya wants to merge 1 commit into
google:mainfrom
vinsymoyya:fix/excluded-directory-prefix

Conversation

@vinsymoyya

Copy link
Copy Markdown

Fixes #1340.

Excluding build during a recursive run also drops build_tools and build2, because _FindPythonFiles treats any raw path prefix as a descendant of an excluded directory. This can make a quiet formatting check return success while an unformatted sibling file is never checked.

Require a directory separator after the excluded path when testing descendants. Keep exact exclusions, recursive pruning, and explicit glob patterns unchanged. Add real-filesystem regression tests for absolute and relative discovery, prefix-sharing siblings and their descendants, and intentional build* exclusions.

Validation on Windows, Python 3.12.13:

  • The new sibling regression fails on upstream main for both absolute and relative paths; the glob-preservation test passes before and after the fix.
  • python -m pytest -q yapftests/file_resources_test.py: 40 passed, 2 subtests passed.
  • python -m pytest -q: 613 passed, 2 subtests passed.
  • Changed files pass flake8, isort, YAPF formatting, and git diff --check.
  • Compared the actual CLI on an archive of upstream main and this branch: the original quiet check incorrectly exits 0; the fixed check exits 1. In-place formatting on the fixed branch updates the sibling files and leaves excluded files unchanged.

Upstream CI and maintainer review are pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excluding a directory also skips siblings whose names share its prefix

1 participant