Skip to content

Commit

Permalink
Remove extra call in mapper contains (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed Mar 15, 2024
1 parent 00c8a41 commit c2ab54d
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit c2ab54d

Please sign in to comment.