From ece87405e33b7f617bf11142066b913049c7d660 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 12 Oct 2024 20:48:37 +0200 Subject: [PATCH 1/2] Apply ruff/flynt rule FLY002 FLY002 Consider f-string instead of string join --- fsspec/gui.py | 2 +- fsspec/implementations/reference.py | 6 ++---- fsspec/utils.py | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fsspec/gui.py b/fsspec/gui.py index 321379eb8..4755ad813 100644 --- a/fsspec/gui.py +++ b/fsspec/gui.py @@ -119,7 +119,7 @@ def _signal(self, event): widget components. """ if not self._ignoring_events: - wn = "-".join([event.obj.name, event.name]) + wn = f"{event.obj.name}-{event.name}" if wn in self._map and self._map[wn] in self._sigs: self._emit(self._map[wn], event.new) diff --git a/fsspec/implementations/reference.py b/fsspec/implementations/reference.py index 2df8b0e0d..c3f1e078e 100644 --- a/fsspec/implementations/reference.py +++ b/fsspec/implementations/reference.py @@ -160,9 +160,7 @@ def __getattr__(self, item): def setup(self): self._items = {} - self._items[".zmetadata"] = self.fs.cat_file( - "/".join([self.root, ".zmetadata"]) - ) + self._items[".zmetadata"] = self.fs.cat_file(f"{self.root}/.zmetadata") met = json.loads(self._items[".zmetadata"]) self.record_size = met["record_size"] self.zmetadata = met["metadata"] @@ -210,7 +208,7 @@ def create(root, storage_options=None, fs=None, record_size=10000, **kwargs): if fs.exists(root): fs.rm(root, recursive=True) fs.makedirs(root, exist_ok=True) - fs.pipe("/".join([root, ".zmetadata"]), json.dumps(met).encode()) + fs.pipe(f"{root}/.zmetadata", json.dumps(met).encode()) return LazyReferenceMapper(root, fs, **kwargs) @lru_cache() diff --git a/fsspec/utils.py b/fsspec/utils.py index 3c624be9c..b020cc8bd 100644 --- a/fsspec/utils.py +++ b/fsspec/utils.py @@ -74,7 +74,7 @@ def infer_storage_options( parsed_path = urlsplit(urlpath) protocol = parsed_path.scheme or "file" if parsed_path.fragment: - path = "#".join([parsed_path.path, parsed_path.fragment]) + path = f"{parsed_path.path}#{parsed_path.fragment}" else: path = parsed_path.path if protocol == "file": @@ -415,7 +415,7 @@ def other_paths( if exists: cp = cp.rsplit("/", 1)[0] if not cp and all(not s.startswith("/") for s in paths): - path2 = ["/".join([path2, p]) for p in paths] + path2 = [f"{path2}/{p}" for p in paths] else: path2 = [p.replace(cp, path2, 1) for p in paths] else: From 97a499aa34830c1d5cb6f0646515cbb0ed0eaeca Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 12 Oct 2024 20:49:20 +0200 Subject: [PATCH 2/2] Enforce ruff/flynt rules (FLY) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ef707f50d..01a712039 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -162,6 +162,7 @@ select = [ "E7", "E9", "F", + "FLY", "FURB", "I", "LOG",