From 223c62855b94c73f4f3a31a75ed0cdcad491d80d Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Thu, 23 Jul 2026 18:09:18 -0400 Subject: [PATCH] Fix lint errors Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com> --- fsspec_python/importer.py | 14 ++++++-------- fsspec_python/tests/test_all.py | 2 +- fsspec_python/utils.py | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fsspec_python/importer.py b/fsspec_python/importer.py index 7dc96e9..fed5197 100644 --- a/fsspec_python/importer.py +++ b/fsspec_python/importer.py @@ -5,7 +5,7 @@ from importlib.machinery import SOURCE_SUFFIXES, ModuleSpec from os.path import join from types import ModuleType -from typing import TYPE_CHECKING, Dict, Union +from typing import TYPE_CHECKING from fsspec import url_to_fs from fsspec.implementations.local import AbstractFileSystem @@ -55,7 +55,7 @@ def __eq__(self, other: object) -> bool: # Singleton for use elsewhere -_finders: Dict[str, FSSpecImportFinder] = {} +_finders: dict[str, FSSpecImportFinder] = {} class FSSpecImportLoader(SourceLoader): @@ -64,7 +64,7 @@ def __init__(self, fullname: str, path: str, fs: PythonFileSystem): self.path = path self.fs = fs - def get_filename(self, fullname: str) -> str: # noqa: ARG002 + def get_filename(self, fullname: str) -> str: return self.path def get_data(self, path: str | bytes) -> bytes: @@ -76,18 +76,17 @@ def get_data(self, path: str | bytes) -> bytes: # source = source_bytes.decode("utf-8") -def install_importer(fs: Union[str, AbstractFileSystem], **kwargs: str) -> FSSpecImportFinder: +def install_importer(fs: str | AbstractFileSystem, **kwargs: str) -> FSSpecImportFinder: """Install the fsspec importer.""" if isinstance(fs, AbstractFileSystem): fsspec_str = normalize_fsspec(fs=fs, **kwargs) elif not isinstance(fs, str): - raise ValueError("fs must be a string or AbstractFileSystem instance") + raise TypeError("fs must be a string or AbstractFileSystem instance") else: fsspec_str = fs assert "fo" not in kwargs, "fo cannot be used with string fs" fs, kwargs["fo"] = url_to_fs(fsspec_str) - global _finders if fsspec_str not in _finders: python_fs = fs if isinstance(fs, PythonFileSystem) else PythonFileSystem(fs=fs, install=False, **kwargs) @@ -97,9 +96,8 @@ def install_importer(fs: Union[str, AbstractFileSystem], **kwargs: str) -> FSSpe return _finders[fsspec_str].fs -def uninstall_importer(fs: Union[str, AbstractFileSystem] = "") -> None: +def uninstall_importer(fs: str | AbstractFileSystem = "") -> None: """Uninstall the fsspec importer.""" - global _finders if not _finders: return diff --git a/fsspec_python/tests/test_all.py b/fsspec_python/tests/test_all.py index 46046f6..63de4c6 100644 --- a/fsspec_python/tests/test_all.py +++ b/fsspec_python/tests/test_all.py @@ -1,4 +1,4 @@ -from fsspec_python import * # noqa +from fsspec_python import * def test_all(): diff --git a/fsspec_python/utils.py b/fsspec_python/utils.py index 293cb26..2b78eac 100644 --- a/fsspec_python/utils.py +++ b/fsspec_python/utils.py @@ -5,8 +5,8 @@ def normalize_fsspec( fs: AbstractFileSystem = None, - target_protocol: str = None, - target_options: dict = None, + target_protocol: str | None = None, + target_options: dict | None = None, fo: str = "", **kwargs, ):