Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra call in mapper contains #1546

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions fsspec/mapping.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import array
import logging
import posixpath
import warnings
from collections.abc import MutableMapping
from functools import cached_property

from .core import url_to_fs
from fsspec.core import url_to_fs

logger = logging.getLogger("fsspec.mapping")


class FSMap(MutableMapping):
Expand Down Expand Up @@ -69,6 +72,7 @@ def dirfs(self):

def clear(self):
"""Remove all keys below root - empties out mapping"""
logger.info("Clear mapping at %s", self.root)
try:
self.fs.rm(self.root, True)
self.fs.mkdir(self.root)
Expand Down Expand Up @@ -186,7 +190,7 @@ def __delitem__(self, key):
def __contains__(self, key):
"""Does key exist in mapping?"""
path = self._key_to_str(key)
return self.fs.exists(path) and self.fs.isfile(path)
return self.fs.isfile(path)

def __reduce__(self):
return FSMap, (self.root, self.fs, False, False, self.missing_exceptions)
Expand Down
Loading