Repository navigation
Raise FileNotFoundError from archive ls for a missing path - #2145
Merged
Merged
Conversation
AbstractArchiveFileSystem.ls returned [] for a path that does not exist in the archive, and for a file, instead of raising FileNotFoundError or listing the file like other filesystems. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
With ls listing a file as itself, find on a single archive member returns its info instead of the empty placeholder the base find used when ls came back empty. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Author
|
CI caught a test I hadn't run: |
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.
AbstractArchiveFileSystem.ls(used by zip, tar and libarchive) returns[]in two cases where other filesystems don't:info("i-do-not-exist")already raisesFileNotFoundErroron the same filesystem, andLocalFileSystem,MemoryFileSystemand the object stores raise fromlstoo. Returning an empty list makes a typo look like an empty directory.Change
When nothing is listed under a non-root path,
lsnow falls back toinfo:FileNotFoundError;[].Listing the root of an empty archive still returns
[](test_empty), and listings that find entries are unchanged.Tests
Added
TestAnyArchive.test_ls_file_or_missing, which runs for zip, tar, tar.gz, tar.bz2, tar.xz and libarchive. It fails againstmaster'sarchive.pyfor every scenario that runs here (libarchive isn't installed locally, so it's skipped) and passes with the change.test_archive.py,test_zip.py,test_tar.py,test_libarchive.pyandfsspec/tests/test_api.py: 193 passed, 21 skipped.ruff0.14.3 check and format are clean.🤖 Generated with Claude Code