Skip to content

Correct the hidden-directory traversal example - #283

Open
Ayham970 wants to merge 1 commit into
jaraco:mainfrom
Ayham970:fix-traversal-hidden-directory-example
Open

Ayham970 wants to merge 1 commit into
jaraco:mainfrom
Ayham970:fix-traversal-hidden-directory-example

Conversation

@Ayham970

Copy link
Copy Markdown

The Traversal example checks item.startswith('.') while walking Path('.'). Every child path then starts with ./ (or .\ on Windows), so the example skips ordinary directories along with hidden ones. With an absolute starting path, the predicate can instead try to descend into files.

Check item.is_dir() and item.name in the example. Build a temporary tree in the doctest so it demonstrates both visiting an ordinary directory's file and skipping a hidden directory's contents, without depending on the checkout's contents. This changes the documentation example only; traversal behavior is unchanged.

Validation on Windows / Python 3.13:

  • The new doctest fails with the original predicate and passes with the correction.
  • tox -e py313 ran the suite, formatting, and type checks: 146 passed, 7 skipped, and 12 failures/errors, all at symbolic-link creation with WinError 1314 (the local session lacks that privilege). Formatting and mypy passed.
  • tox -e docs: the Sphinx build with warnings treated as errors and sphinx-lint both passed.

AI disclosure: OpenAI Codex prepared this change and ran the local validation.

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.

1 participant