Skip to content

Commit 18f99f0

Browse files
alanhdumartindurant
andcommitted
Apply suggestions from code review
Co-authored-by: Martin Durant <[email protected]>
1 parent 322bf74 commit 18f99f0

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

fsspec/caching.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def __getstate__(self) -> dict[str, Any]:
144144
del state["cache"]
145145
return state
146146

147-
def __setstate__(self, state) -> None:
147+
def __setstate__(self, state: dict[str, Any]) -> None:
148148
# Restore instance attributes
149149
self.__dict__.update(state)
150150
self.cache = self._makefile()
@@ -278,7 +278,7 @@ def __getstate__(self) -> dict[str, Any]:
278278
del state["_fetch_block_cached"]
279279
return state
280280

281-
def __setstate__(self, state) -> None:
281+
def __setstate__(self, state: dict[str, Any]) -> None:
282282
self.__dict__.update(state)
283283
self._fetch_block_cached = functools.lru_cache(state["maxblocks"])(
284284
self._fetch_block
@@ -471,10 +471,6 @@ def __init__(
471471
self.data = data
472472

473473
def _fetch(self, start: int | None, stop: int | None) -> bytes:
474-
if start is None:
475-
start = 0
476-
if stop is None:
477-
stop = len(self.data)
478474
return self.data[start:stop]
479475

480476

fsspec/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,7 @@ def read_block(
296296
length = end - start
297297

298298
f.seek(offset)
299-
if length is not None:
300-
b = f.read(length)
301-
else:
302-
b = f.read()
299+
b = f.read(length) # type: ignore[arg-type]
303300
return b
304301

305302

@@ -348,14 +345,14 @@ def stringify_path(filepath: str | os.PathLike[str] | pathlib.Path) -> str:
348345
"""
349346
if isinstance(filepath, str):
350347
return filepath
351-
elif hasattr(filepath, "__fspath__") or isinstance(filepath, os.PathLike):
348+
elif hasattr(filepath, "__fspath__"):
352349
return filepath.__fspath__()
353350
elif isinstance(filepath, pathlib.Path):
354351
return str(filepath)
355352
elif hasattr(filepath, "path"):
356353
return filepath.path
357354
else:
358-
return filepath
355+
return filepath # type: ignore[return-value]
359356

360357

361358
def make_instance(

0 commit comments

Comments
 (0)