Skip to content

Commit 6cb1581

Browse files
authored
Merge pull request #46 from 1kbgz/copier-update-2026-10-11T11-19-32Z
Update from Copier (2026-10-11T11-19-32Z)
2 parents 8c8e9a0 + 3a1c033 commit 6cb1581

10 files changed

Lines changed: 26 additions & 25 deletions

File tree

‎.copier-answers.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 7d58f0e
2+
_commit: '4372075'
33
_src_path: https://github.com/python-project-templates/base.git
44
add_docs: false
55
add_extension: python

‎.github/workflows/build.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
workflow_dispatch:
1616

1717
concurrency:
18-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
group: ${{ github.workflow }}-${{ github.ref }}
1919
cancel-in-progress: true
2020

2121
permissions:

‎Makefile‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ lint-py: ## lint python with ruff
2525
python -m ruff format --check fsspec_python
2626

2727
lint-docs: ## lint docs with mdformat and codespell
28-
python -m mdformat --check README.md
29-
python -m codespell_lib README.md
28+
python -m mdformat --check README.md $(wildcard docs/src)
29+
python -m codespell_lib README.md $(wildcard docs/src)
3030

3131
fix-py: ## autoformat python code with ruff
3232
python -m ruff check --fix fsspec_python
3333
python -m ruff format fsspec_python
3434

3535
fix-docs: ## autoformat docs with mdformat and codespell
36-
python -m mdformat README.md
37-
python -m codespell_lib --write README.md
36+
python -m mdformat README.md $(wildcard docs/src)
37+
python -m codespell_lib --write README.md $(wildcard docs/src)
3838

3939
lint: lint-py lint-docs ## run all linters
4040
lints: lint
@@ -50,9 +50,9 @@ check-dist: ## check python sdist and wheel with check-dist
5050
check-dist -v
5151

5252
check-types: ## check python types with ty
53-
ty check --python $$(which python)
53+
ty check --python "$$(python -c 'import sys; print(sys.executable)')"
5454

55-
checks: check-dist
55+
checks: check-dist check-types
5656

5757
# Alias
5858
check: checks

‎fsspec_python/fs.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import inspect
4+
from typing import ClassVar
45

56
from fsspec import filesystem, register_implementation
67
from fsspec.implementations.chained import ChainedFileSystem
@@ -11,7 +12,7 @@
1112
class PythonFileSystem(ChainedFileSystem):
1213
"""Python import filesystem"""
1314

14-
protocol: str = "python"
15+
protocol: ClassVar[str] = "python"
1516
root: str = "/"
1617

1718
def __init__(self, target_protocol=None, target_options=None, fs=None, install: bool = True, **kwargs):
@@ -29,11 +30,11 @@ def __init__(self, target_protocol=None, target_options=None, fs=None, install:
2930
raise ValueError("Both filesystems (fs) and target_protocol may not be both given.")
3031

3132
target_options = target_options or {}
33+
self.fs = fs if fs is not None else filesystem(target_protocol, **target_options)
3234
self.target_protocol = (
33-
target_protocol if isinstance(target_protocol, str) else (fs.protocol if isinstance(fs.protocol, str) else fs.protocol[0])
35+
target_protocol if isinstance(target_protocol, str) else (self.fs.protocol if isinstance(self.fs.protocol, str) else self.fs.protocol[0])
3436
)
3537

36-
self.fs = fs if fs is not None else filesystem(target_protocol, **target_options)
3738
if isinstance(self.fs, ChainedFileSystem):
3839
self.root = "/"
3940
kwargs.pop("fo", None)

‎fsspec_python/importer.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from importlib.machinery import SOURCE_SUFFIXES, ModuleSpec
66
from os.path import join
77
from types import ModuleType
8-
from typing import TYPE_CHECKING
8+
from typing import TYPE_CHECKING, Any
99

1010
from fsspec import url_to_fs
1111
from fsspec.implementations.local import AbstractFileSystem
@@ -28,7 +28,7 @@
2828
class FSSpecImportFinder(MetaPathFinder):
2929
def __init__(self, fs: PythonFileSystem) -> None:
3030
self.fs: PythonFileSystem = fs
31-
self.remote_modules: dict[str, str] = {}
31+
self.remote_modules: dict[str, ModuleSpec] = {}
3232

3333
def find_spec(self, fullname: str, path: Sequence[str | bytes] | None, target: ModuleType | None = None) -> ModuleSpec | None:
3434
for suffix in SOURCE_SUFFIXES:
@@ -76,7 +76,7 @@ def get_data(self, path: str | bytes) -> bytes:
7676
# source = source_bytes.decode("utf-8")
7777

7878

79-
def install_importer(fs: str | AbstractFileSystem, **kwargs: str) -> FSSpecImportFinder:
79+
def install_importer(fs: str | AbstractFileSystem, **kwargs: Any) -> PythonFileSystem:
8080
"""Install the fsspec importer."""
8181
if isinstance(fs, AbstractFileSystem):
8282
fsspec_str = normalize_fsspec(fs=fs, **kwargs)
@@ -106,9 +106,8 @@ def uninstall_importer(fs: str | AbstractFileSystem = "") -> None:
106106
fsspec_str = normalize_fsspec(fs=fs) if isinstance(fs, AbstractFileSystem) else fs
107107

108108
if fsspec_str in _finders:
109-
finder = _finders.pop(fsspec_str, None)
110-
if finder:
111-
finder.unload()
109+
finder = _finders.pop(fsspec_str)
110+
finder.unload()
112111
if finder in sys.meta_path:
113112
sys.meta_path.remove(finder)
114113
return

‎fsspec_python/open.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
_original_open = builtins.open
1111

1212
# Patch fsspec's local open to avoid recursion
13-
fsspec.implementations.local.open = _original_open
13+
vars(fsspec.implementations.local)["open"] = _original_open
1414

1515

1616
def install_open_hook(fsspec: str, **fsspec_args):
@@ -24,7 +24,7 @@ def open_from_fsspec(file, mode="r", buffering=-1, encoding=None, errors=None, n
2424
return fsspec_fs.open(filename, mode=mode, encoding=encoding, errors=errors, newline=newline)
2525
return _original_open(file, mode, buffering, encoding, errors, newline, closefd, opener)
2626

27-
builtins.open = open_from_fsspec
27+
vars(builtins)["open"] = open_from_fsspec
2828
globals()["open"] = open_from_fsspec
2929

3030

‎fsspec_python/tests/test_fs.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class TestFs:
77
def test_fs_import(self, fs_importer):
8-
import my_local_file2
8+
import my_local_file2 # ty: ignore[unresolved-import] # Module provided by the filesystem import fixture.
99

1010
assert my_local_file2.baz() == "This is a local file."
1111

‎fsspec_python/tests/test_remote_import.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
class TestRemoteImport:
77
@pytest.mark.skipif(not os.environ.get("FSSPEC_S3_ENDPOINT_URL"), reason="S3 not configured")
88
def test_importer_s3(self, s3_importer):
9-
import my_remote_file
9+
import my_remote_file # ty: ignore[unresolved-import] # Module provided by the filesystem import fixture.
1010

1111
assert my_remote_file.foo() == "This is a remote file."
1212

1313
def test_importer_local(self, local_importer):
14-
import my_local_file
14+
import my_local_file # ty: ignore[unresolved-import] # Module provided by the filesystem import fixture.
1515

1616
assert my_local_file.bar() == "This is a local file."
1717

1818
def test_importer_local_multi(self, local_importer_multi):
1919
import fsspec_python.importer
2020

2121
assert len(fsspec_python.importer._finders) == 2
22-
import my_local_file
23-
import my_local_file2
22+
import my_local_file # ty: ignore[unresolved-import] # Module provided by the filesystem import fixture.
23+
import my_local_file2 # ty: ignore[unresolved-import] # Module provided by the filesystem import fixture.
2424

2525
assert my_local_file.bar() == "This is a local file."
2626
assert my_local_file2.baz() == "This is a local file."

‎fsspec_python/utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def normalize_fsspec(
7-
fs: AbstractFileSystem = None,
7+
fs: AbstractFileSystem | None = None,
88
target_protocol: str | None = None,
99
target_options: dict | None = None,
1010
fo: str = "",

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ develop = [
4343
"codespell",
4444
"hatchling",
4545
"mdformat",
46+
"mdformat-frontmatter",
4647
"mdformat-tables>=1",
4748
"pytest",
4849
"pytest-cov",

0 commit comments

Comments
 (0)