Conversation
…ted in HfPath.iterdir Newer huggingface_hub releases raise ValueError instead of NotImplementedError when asked to list a namespace such as a user's repositories, which made test_iterdir_parent_iteration fail. Fixes fsspec#562 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
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.
Towards #559.
UPath.rmdir()removes a non-empty directory and everything in it, whilePosixUPath/WindowsUPathand a wrappedpathlib.PathraiseOSError, because they go throughpathlib.Path.rmdir(). Same call, same local directory, two outcomes depending on how the path was spelled:As suggested in the issue, this does not change behaviour yet.
recursivenow defaults toUNSET_DEFAULT, and when it is not given and the directory is not empty,rmdir()warns:Passing
recursive=Trueorrecursive=Falseexplicitly is unchanged and silent, so callers can opt out of the warning now and keep working after the default flips. Thepathlib-backed classes already behave the way 0.4.0 will, so they do not warn.One small fix comes along: the emptiness check was
next(self.iterdir()), which raisedStopIterationon an empty directory instead of falling through. It is nownext(self.iterdir(), None).Tests
test_rmdir_not_empty_warns_about_the_future_defaultandtest_rmdir_not_empty_recursive_does_not_warnin the sharedBaseTests, so every implementation is covered, with an override inTestProxyPathlibPathwhere the wrappedpathlib.Pathraises instead.Local suite: 2443 passed.
test_pathlib_backport.py::test_signature_glob_pathlike[memory]fails onmainhere too, and the hdfs errors are a missing optional dependency.Not in this PR
rmdir(recursive=False)on an empty directory callsfs.rm(..., recursive=False), which fsspec'sLocalFileSystemrejects withValueError: Cannot delete directory, set recursive=True. That is separate from the default change, so I left it alone; happy to follow up if you want it fixed before 0.4.0, since it becomes the common path once the default flips.