Fix _cat_file / _cat_ranges not discoverable on WholeFileCacheFileSystem class#2010
Merged
martindurant merged 2 commits intofsspec:masterfrom Apr 14, 2026
Merged
Conversation
Move _cat_file and _cat_ranges from SimpleCacheFileSystem to WholeFileCacheFileSystem so that these methods are discoverable via type(fs) and not only via instance attribute lookup. Also add a guard in CachingFileSystem.__getattribute__ so that whitelisted methods not defined on the current subclass fall through to the wrapped filesystem delegation instead of returning a broken lambda. Closes fsspec#2009
_cat_file and _cat_ranges missing on WholeFileCacheFileSystem class_cat_file / _cat_ranges not discoverable on WholeFileCacheFileSystem class
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.
Fixes #2009
Problem
hasattr(type(fs), '_cat_file')returnsFalseforWholeFileCacheFileSystem, even thoughhasattr(fs, '_cat_file')returnsTrue. This is becauseCachingFileSystem.__getattribute__intercepts attribute access at the instance level, but the method is never defined on the class itself.Libraries like
universal_pathlibandzarrinspect capabilities viatype(fs)rather than the instance, which leads toAttributeError.Fix
Two changes:
Move
_cat_fileand_cat_rangesfromSimpleCacheFileSystemup toWholeFileCacheFileSystem. Both classes use the same whole-file caching logic (check cache, download if missing, read locally).SimpleCacheFileSysteminherits them unchanged.Guard the whitelist in
__getattribute__: the whitelist is shared across the hierarchy, but some entries only exist on certain subclasses. When a whitelisted method is not ontype(self), we now fall through to the wrapped filesystem delegation instead of returning a lambda that would raiseAttributeError.Note to maintainers
If this instance-only delegation is intentional by design, or if you'd prefer a different approach, happy to hear your guidance. We can adjust or close this accordingly.