Skip to content

Commit 4e29445

Browse files
committed
Enable way more rules and add fixes or noqas
1 parent 0a13d4a commit 4e29445

File tree

15 files changed

+52
-21
lines changed

15 files changed

+52
-21
lines changed

fsspec/exceptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ class BlocksizeMismatchError(ValueError):
1010
written with
1111
"""
1212

13-
...
1413

1514

1615
class FSTimeoutError(asyncio.TimeoutError):
1716
"""
1817
Raised when a fsspec function timed out occurs
1918
"""
2019

21-
...

fsspec/gui.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ def _emit(self, sig, value=None):
153153
break
154154
except Exception as e:
155155
logger.exception(
156-
"Exception (%s) while executing callback for signal: %s"
157-
"" % (e, sig)
156+
"Exception (%s) while executing callback for signal: %s",
157+
e,
158+
sig,
158159
)
159160

160161
def show(self, threads=False):

fsspec/implementations/cache_mapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AbstractCacheMapper(abc.ABC):
1919
def __call__(self, path: str) -> str:
2020
...
2121

22-
def __eq__(self, other: Any) -> bool:
22+
def __eq__(self, other: object) -> bool:
2323
# Identity only depends on class. When derived classes have attributes
2424
# they will need to be included.
2525
return isinstance(other, type(self))
@@ -56,7 +56,7 @@ def __call__(self, path: str) -> str:
5656
else:
5757
return prefix # No separator found, simple filename
5858

59-
def __eq__(self, other: Any) -> bool:
59+
def __eq__(self, other: object) -> bool:
6060
return super().__eq__(other) and self.directory_levels == other.directory_levels
6161

6262
def __hash__(self) -> int:

fsspec/implementations/http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ async def _get_file(
251251
if isfilelike(lpath):
252252
outfile = lpath
253253
else:
254-
outfile = open(lpath, "wb")
254+
outfile = open(lpath, "wb") # noqa: ASYNC101
255255

256256
try:
257257
chunk = True
@@ -279,7 +279,7 @@ async def gen_chunks():
279279
context = nullcontext(lpath)
280280
use_seek = False # might not support seeking
281281
else:
282-
context = open(lpath, "rb")
282+
context = open(lpath, "rb") # noqa: ASYNC101
283283
use_seek = True
284284

285285
with context as f:
@@ -801,7 +801,7 @@ async def get_range(session, url, start, end, file=None, **kwargs):
801801
async with r:
802802
out = await r.read()
803803
if file:
804-
with open(file, "r+b") as f:
804+
with open(file, "r+b") as f: # noqa: ASYNC101
805805
f.seek(start)
806806
f.write(out)
807807
else:

fsspec/implementations/tests/test_cached.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ def test_multi_cache(protocol):
10221022
def test_multi_cat(protocol, ftp_writable):
10231023
host, port, user, pw = ftp_writable
10241024
fs = FTPFileSystem(host, port, user, pw)
1025-
for fn in {"/file0", "/file1"}:
1025+
for fn in ("/file0", "/file1"):
10261026
with fs.open(fn, "wb") as f:
10271027
f.write(b"hello")
10281028

fsspec/implementations/tests/test_dirfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ async def _walk(path, *args, **kwargs):
355355

356356
actual = []
357357
async for entry in adirfs._walk("root", *ARGS, **KWARGS):
358-
actual.append(entry)
358+
actual.append(entry) # noqa: PERF402
359359
assert actual == [("root", ["foo", "bar"], ["baz", "qux"])]
360360
adirfs.fs._walk.assert_called_once_with(f"{PATH}/root", *ARGS, **KWARGS)
361361

fsspec/implementations/tests/test_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ async def test_async_walk(server):
557557
# No maxdepth
558558
res = []
559559
async for a in fs._walk(server + "/index"):
560-
res.append(a)
560+
res.append(a) # noqa: PERF402
561561
assert res == [(server + "/index", [], ["realfile"])]
562562

563563
# maxdepth=0

fsspec/implementations/tests/test_reference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def test_nested_dirs_ls():
6161
refs = {"a": "A", "B/C/b": "B", "B/C/d": "d", "B/_": "_"}
6262
fs = fsspec.filesystem("reference", fo=refs)
6363
assert len(fs.ls("")) == 2
64-
assert set(e["name"] for e in fs.ls("")) == set(["a", "B"])
64+
assert {e["name"] for e in fs.ls("")} == {"a", "B"}
6565
assert len(fs.ls("B")) == 2
66-
assert set(e["name"] for e in fs.ls("B")) == set(["B/C", "B/_"])
66+
assert {e["name"] for e in fs.ls("B")} == {"B/C", "B/_"}
6767

6868

6969
def test_info(server): # noqa: F811

fsspec/implementations/tests/test_tar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_info():
4242
assert lhs == expected
4343

4444
# Iterate over all files.
45-
for f, v in archive_data.items():
45+
for f in archive_data.keys():
4646
lhs = fs.info(f)
4747

4848
# Probe some specific fields of Tar archives.

fsspec/implementations/tests/test_zip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_info():
1212
fs = fsspec.filesystem("zip", fo=z)
1313

1414
# Iterate over all files.
15-
for f, v in archive_data.items():
15+
for f in archive_data.keys():
1616
lhs = fs.info(f)
1717

1818
# Probe some specific fields of Zip archives.

0 commit comments

Comments
 (0)