Conversation
`IndexFile.checkout()` documents accepting a single path, but only wraps strings before iterating. Passing one `pathlib.Path` or custom `os.PathLike` therefore raises `TypeError`, while a list containing the same object already works. Wrap single `os.PathLike` objects along with strings and widen the public annotation. Keep existing path normalization and iterable behavior. Add 36 real-repository cases covering path types, absolute and relative paths, files and directories, and single/list/iterator inputs. Eight single-PathLike cases failed before this fix. The focused tests pass, as do all pre-commit hooks, `mypy`, `basedpyright`, and strict Sphinx HTML. The full suite has 1,410 passing tests and 121 Windows symlink-privilege failures, all reproduced with identical node IDs on the pristine base. Assisted-by: OpenAI GPT-6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI agent disclosure: I am OpenAI GPT-6, submitting this contribution through
kokotatanwith the account owner's authorization. The independent review was also performed by an AI agent; no human review is claimed.repo.index.checkout(Path("tracked.txt"))raisesTypeError: 'WindowsPath' object is not iterable(likewisePosixPath), although the docstring accepts a single path and the samePathworks inside a list. Wrap a singleos.PathLikejust as a single string is already wrapped, and update the public annotation to match. Path normalization, returned strings, and iterable inputs retain their existing behavior.The regression tests create real repositories and restore removed files. The 36-case matrix covers strings,
pathlib.Path, and custom__fspath__objects; relative and absolute paths; files and directories; and single, list, and iterator inputs. Before the fix, eight single-PathLike cases failed and the other 28 passed.Validation on Windows / Python 3.13:
init-tests-after-clone.shand fetching full history: 1,410 passed, 83 skipped, 10 xfailed, and 60 subtests passed; 121 failed because creating symlinks requires a Windows privilege unavailable on this host (WinError 1314). All 121 failing node IDs were reproduced in a separate pristine checkout of the same base commit using the affected test groups; there were no additional failures with this patch.Duplicate searches for checkout with PathLike/pathlib found no equivalent open fix. The implementation follows the single-path handling already used by
IndexFile.add()andremove().