Skip to content

Commit 97e5913

Browse files
Ruff legacy alias (#1887)
1 parent 57b7381 commit 97e5913

File tree

14 files changed

+32
-46
lines changed

14 files changed

+32
-46
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ repos:
1313
- id: check-json
1414
- id: check-yaml
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
# Ruff version.
17-
rev: v0.11.13
16+
rev: v0.12.2
1817
hooks:
1918
# Run the linter.
20-
- id: ruff
19+
- id: ruff-check
2120
args: [ --fix, "--show-fixes"]
2221
- id: ruff-format
2322
types_or: [python]

fsspec/asyn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import os
88
import re
99
import threading
10+
from collections.abc import Iterable
1011
from glob import has_magic
11-
from typing import TYPE_CHECKING, Iterable
12+
from typing import TYPE_CHECKING
1213

1314
from .callbacks import DEFAULT_CALLBACK
1415
from .exceptions import FSTimeoutError

fsspec/caching.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import threading
99
import warnings
10+
from collections import OrderedDict
1011
from concurrent.futures import Future, ThreadPoolExecutor
1112
from itertools import groupby
1213
from operator import itemgetter
@@ -17,8 +18,6 @@
1718
ClassVar,
1819
Generic,
1920
NamedTuple,
20-
Optional,
21-
OrderedDict,
2221
TypeVar,
2322
)
2423

@@ -629,7 +628,7 @@ def __init__(
629628
blocksize: int,
630629
fetcher: Fetcher,
631630
size: int,
632-
data: Optional[dict[tuple[int, int], bytes]] = None,
631+
data: dict[tuple[int, int], bytes] | None = None,
633632
strict: bool = True,
634633
**_: Any,
635634
):

fsspec/generic.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
import shutil
77
import uuid
8-
from typing import Optional
98

109
from .asyn import AsyncFileSystem, _run_coros_in_chunks, sync_wrapper
1110
from .callbacks import DEFAULT_CALLBACK
@@ -289,7 +288,7 @@ async def _cp_file(
289288
url2,
290289
blocksize=2**20,
291290
callback=DEFAULT_CALLBACK,
292-
tempdir: Optional[str] = None,
291+
tempdir: str | None = None,
293292
**kwargs,
294293
):
295294
fs = _resolve_fs(url, self.method)
@@ -319,9 +318,9 @@ async def _copy(
319318
path2: list[str],
320319
recursive: bool = False,
321320
on_error: str = "ignore",
322-
maxdepth: Optional[int] = None,
323-
batch_size: Optional[int] = None,
324-
tempdir: Optional[str] = None,
321+
maxdepth: int | None = None,
322+
batch_size: int | None = None,
323+
tempdir: str | None = None,
325324
**kwargs,
326325
):
327326
# TODO: special case for one FS being local, which can use get/put

fsspec/gui.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import logging
44
import os
55
import re
6-
from typing import ClassVar, Sequence
6+
from collections.abc import Sequence
7+
from typing import ClassVar
78

89
import panel as pn
910

fsspec/implementations/cache_metadata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
import json
1515

1616
if TYPE_CHECKING:
17-
from typing import Any, Dict, Iterator, Literal
17+
from collections.abc import Iterator
18+
from typing import Any, Literal
1819

1920
from typing_extensions import TypeAlias
2021

2122
from .cached import CachingFileSystem
2223

23-
Detail: TypeAlias = Dict[str, Any]
24+
Detail: TypeAlias = dict[str, Any]
2425

2526

2627
class CacheMetadata:

fsspec/implementations/cached.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def _open(
339339
# explicitly submitting the size to the open call will avoid extra
340340
# operations when opening. This is particularly relevant
341341
# for any file that is read over a network, e.g. S3.
342-
size = detail.get("size", None)
342+
size = detail.get("size")
343343

344344
# call target filesystems open
345345
self._mkcache()

fsspec/implementations/ftp.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
2-
import sys
32
import uuid
4-
import warnings
53
from ftplib import FTP, FTP_TLS, Error, error_perm
64
from typing import Any
75

@@ -81,13 +79,7 @@ def _connect(self):
8179
ftp_cls = FTP_TLS
8280
else:
8381
ftp_cls = FTP
84-
if sys.version_info >= (3, 9):
85-
self.ftp = ftp_cls(timeout=self.timeout, encoding=self.encoding)
86-
elif self.encoding:
87-
warnings.warn("`encoding` not supported for python<3.9, ignoring")
88-
self.ftp = ftp_cls(timeout=self.timeout)
89-
else:
90-
self.ftp = ftp_cls(timeout=self.timeout)
82+
self.ftp = ftp_cls(timeout=self.timeout, encoding=self.encoding)
9183
self.ftp.connect(self.host, self.port)
9284
self.ftp.login(*self.cred)
9385

fsspec/implementations/git.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def _path_to_object(self, path, ref):
6262

6363
@staticmethod
6464
def _get_kwargs_from_urls(path):
65-
if path.startswith("git://"):
66-
path = path[6:]
65+
path = path.removeprefix("git://")
6766
out = {}
6867
if ":" in path:
6968
out["path"], path = path.split(":", 1)

fsspec/implementations/memory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def _strip_protocol(cls, path):
3434
else:
3535
path = stringify_path(path)
3636

37-
if path.startswith("memory://"):
38-
path = path[len("memory://") :]
37+
path = path.removeprefix("memory://")
3938
if "::" in path or "://" in path:
4039
return path.rstrip("/")
4140
path = path.lstrip("/").rstrip("/")

0 commit comments

Comments
 (0)