Skip to content

Commit f1c2159

Browse files
committed
fix: make typing compatible with 3.8
1 parent 4d6d87c commit f1c2159

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

object-store/object_store/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from __future__ import annotations
2-
31
from io import BytesIO
4-
from typing import List
2+
from typing import List, Optional, Union
53

64
# NOTE aliasing the imports with 'as' makes them public in the eyes
75
# of static code checkers. Thus we avoid listing them with __all__ = ...
@@ -13,12 +11,12 @@
1311
try:
1412
import importlib.metadata as importlib_metadata
1513
except ImportError:
16-
import importlib_metadata
14+
import importlib_metadata # type: ignore
1715

1816
__version__ = importlib_metadata.version("object-store-python")
1917

20-
PathLike = str | List[str] | Path
21-
BytesLike = bytes | BytesIO
18+
PathLike = Union[str, List[str], Path]
19+
BytesLike = Union[bytes, BytesIO]
2220

2321
DELIMITER = "/"
2422

@@ -98,7 +96,7 @@ def delete(self, location: PathLike) -> None:
9896
"""
9997
return super().delete(_as_path(location))
10098

101-
def list(self, prefix: PathLike | None = None) -> list[ObjectMeta]:
99+
def list(self, prefix: Optional[PathLike] = None) -> list[ObjectMeta]:
102100
"""List all the objects with the given prefix.
103101
104102
Prefixes are evaluated on a path segment basis, i.e. `foo/bar/` is a prefix
@@ -113,7 +111,7 @@ def list(self, prefix: PathLike | None = None) -> list[ObjectMeta]:
113111
prefix_ = _as_path(prefix) if prefix else None
114112
return super().list(prefix_)
115113

116-
def list_with_delimiter(self, prefix: PathLike | None = None) -> ListResult:
114+
def list_with_delimiter(self, prefix: Optional[PathLike] = None) -> ListResult:
117115
"""List objects with the given prefix and an implementation specific
118116
delimiter. Returns common prefixes (directories) in addition to object
119117
metadata.

object-store/object_store/arrow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import annotations
1+
from typing import Dict, List, Optional
22

33
import pyarrow as pa
44
import pyarrow.fs as fs
@@ -10,16 +10,16 @@
1010
# _ArrowFileSystemHandler mus be the first element in the inherited classes, we need to also
1111
# inherit form fs.FileSystemHandler to pass pyarrow's type checks.
1212
class ArrowFileSystemHandler(_ArrowFileSystemHandler, fs.FileSystemHandler):
13-
def open_input_file(self, path: str) -> pa.PythonFile:
13+
def open_input_file(self, path: str) -> "pa.PythonFile":
1414
return pa.PythonFile(_ArrowFileSystemHandler.open_input_file(self, path))
1515

16-
def open_input_stream(self, path: str) -> pa.PythonFile:
16+
def open_input_stream(self, path: str) -> "pa.PythonFile":
1717
return pa.PythonFile(_ArrowFileSystemHandler.open_input_file(self, path))
1818

19-
def open_output_stream(self, path: str, metadata: dict[str, str] | None = None) -> pa.PythonFile:
19+
def open_output_stream(self, path: str, metadata: Optional[Dict[str, str]] = None) -> "pa.PythonFile":
2020
return pa.PythonFile(_ArrowFileSystemHandler.open_output_stream(self, path, metadata))
2121

22-
def get_file_info_selector(self, selector: fs.FileSelector) -> list[fs.FileInfo]:
22+
def get_file_info_selector(self, selector: fs.FileSelector) -> List["fs.FileInfo"]:
2323
return _ArrowFileSystemHandler.get_file_info_selector(
2424
self, selector.base_dir, selector.allow_not_found, selector.recursive
2525
)

0 commit comments

Comments
 (0)