Skip to content

Commit df65747

Browse files
dholthmartindurant
andauthored
Fix equality for AbstractBufferedFile != b'' (#1594)
Co-authored-by: Martin Durant <[email protected]>
1 parent 05e8858 commit df65747

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fsspec/spec.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,12 @@ def __eq__(self, other):
16981698
"""Files are equal if they have the same checksum, only in read mode"""
16991699
if self is other:
17001700
return True
1701-
return self.mode == "rb" and other.mode == "rb" and hash(self) == hash(other)
1701+
return (
1702+
isinstance(other, type(self))
1703+
and self.mode == "rb"
1704+
and other.mode == "rb"
1705+
and hash(self) == hash(other)
1706+
)
17021707

17031708
def commit(self):
17041709
"""Move from temp to final destination"""

fsspec/tests/test_spec.py

+4
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,10 @@ def test_eq():
819819
result = fs == 1
820820
assert result is False
821821

822+
f = AbstractBufferedFile(fs, "misc/foo.txt", cache_type="bytes")
823+
result = f == 1
824+
assert result is False
825+
822826

823827
def test_pickle_multiple():
824828
a = DummyTestFS(1)

0 commit comments

Comments
 (0)