Skip to content

Commit a747958

Browse files
committed
Use from __future__ import annotations
1 parent 96b99ad commit a747958

File tree

7 files changed

+24
-15
lines changed

7 files changed

+24
-15
lines changed

fsspec/config.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
from __future__ import annotations
2+
13
import configparser
24
import json
35
import os
46
import warnings
5-
from typing import Any, Dict
7+
from typing import Any
68

7-
conf: Dict[str, Dict[str, Any]] = {}
9+
conf: dict[str, dict[str, Any]] = {}
810
default_conf_dir = os.path.join(os.path.expanduser("~"), ".config/fsspec")
911
conf_dir = os.environ.get("FSSPEC_CONFIG_DIR", default_conf_dir)
1012

fsspec/implementations/cached.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import contextlib
24
import hashlib
35
import inspect
@@ -7,7 +9,7 @@
79
import tempfile
810
import time
911
from shutil import rmtree
10-
from typing import ClassVar, Tuple, Union
12+
from typing import ClassVar
1113

1214
from fsspec import AbstractFileSystem, filesystem
1315
from fsspec.callbacks import _DEFAULT_CALLBACK
@@ -40,7 +42,7 @@ class CachingFileSystem(AbstractFileSystem):
4042
allowed, for testing
4143
"""
4244

43-
protocol: ClassVar[Union[str, Tuple[str, ...]]] = ("blockcache", "cached")
45+
protocol: ClassVar[str | tuple[str, ...]] = ("blockcache", "cached")
4446

4547
def __init__(
4648
self,

fsspec/implementations/memory.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from __future__ import absolute_import, division, print_function
1+
from __future__ import absolute_import, annotations, division, print_function
22

33
import logging
44
from datetime import datetime
55
from errno import ENOTEMPTY
66
from io import BytesIO
7-
from typing import Any, ClassVar, Dict
7+
from typing import Any, ClassVar
88

99
from fsspec import AbstractFileSystem
1010

@@ -18,7 +18,7 @@ class MemoryFileSystem(AbstractFileSystem):
1818
in memory filesystem.
1919
"""
2020

21-
store: ClassVar[Dict[str, Any]] = {} # global, do not overwrite!
21+
store: ClassVar[dict[str, Any]] = {} # global, do not overwrite!
2222
pseudo_dirs = [""] # global, do not overwrite!
2323
protocol = "memory"
2424
root_marker = "/"

fsspec/implementations/tests/test_tar.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from __future__ import annotations
2+
13
import os
24
import shutil
35
import tarfile
46
import tempfile
57
from io import BytesIO
68
from pathlib import Path
7-
from typing import Dict
89

910
import pytest
1011

@@ -210,7 +211,7 @@ def test_ls_with_folders(compression: str, tmp_path: Path):
210211
but make sure that the reading filesystem is still able to resolve the
211212
intermediate folders, like the ZipFileSystem.
212213
"""
213-
tar_data: Dict[str, bytes] = {
214+
tar_data: dict[str, bytes] = {
214215
"a.pdf": b"Hello A!",
215216
"b/c.pdf": b"Hello C!",
216217
"d/e/f.pdf": b"Hello F!",

fsspec/registry.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
from __future__ import annotations
2+
13
import importlib
24
import types
35
import warnings
4-
from typing import Dict, Type
56

67
__all__ = ["registry", "get_filesystem_class", "default"]
78

89
# internal, mutable
9-
_registry: Dict[str, Type] = {}
10+
_registry: dict[str, type] = {}
1011

1112
# external, immutable
1213
registry = types.MappingProxyType(_registry)

fsspec/spec.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import io
24
import logging
35
import os
@@ -7,7 +9,7 @@
79
from errno import ESPIPE
810
from glob import has_magic
911
from hashlib import sha256
10-
from typing import ClassVar, Tuple, Union
12+
from typing import ClassVar
1113

1214
from .callbacks import _DEFAULT_CALLBACK
1315
from .config import apply_config, conf
@@ -102,7 +104,7 @@ class AbstractFileSystem(metaclass=_Cached):
102104
_cached = False
103105
blocksize = 2**22
104106
sep = "/"
105-
protocol: ClassVar[Union[str, Tuple[str, ...]]] = "abstract"
107+
protocol: ClassVar[str | tuple[str, ...]] = "abstract"
106108
_latest = None
107109
async_impl = False
108110
mirror_sync_methods = False

fsspec/utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import logging
24
import math
35
import os
@@ -8,7 +10,6 @@
810
from functools import partial
911
from hashlib import md5
1012
from importlib.metadata import version
11-
from typing import Dict
1213
from urllib.parse import urlsplit
1314

1415
DEFAULT_BLOCK_SIZE = 5 * 2**20
@@ -111,7 +112,7 @@ def update_storage_options(options, inherited=None):
111112

112113

113114
# Compression extensions registered via fsspec.compression.register_compression
114-
compressions: Dict[str, str] = {}
115+
compressions: dict[str, str] = {}
115116

116117

117118
def infer_compression(filename):

0 commit comments

Comments
 (0)