Skip to content

Commit

Permalink
Fix typing compliance with future annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoretti committed Feb 15, 2024
1 parent fe017dd commit 952759e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions exasol/bucketfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
CURL:
$ curl -u "w:write" --output myfile.txt http://127.0.0.1:6666/default/myfile.txt
"""
from __future__ import annotations

import hashlib
from collections import defaultdict
from pathlib import Path
Expand Down Expand Up @@ -142,7 +144,7 @@ def __init__(
self._verify = verify

@property
def buckets(self) -> MutableMapping[str, "Bucket"]:
def buckets(self) -> MutableMapping[str, Bucket]:
"""List all available buckets."""
url = _build_url(service_url=self._url)
response = requests.get(url, verify=self._verify)
Expand All @@ -167,10 +169,10 @@ def buckets(self) -> MutableMapping[str, "Bucket"]:
def __str__(self) -> str:
return f"Service<{self._url}>"

def __iter__(self) -> Iterator["Bucket"]:
def __iter__(self) -> Iterator[Bucket]:
yield from self.buckets

def __getitem__(self, item: str) -> "Bucket":
def __getitem__(self, item: str) -> Bucket:
return self.buckets[item]


Expand Down Expand Up @@ -233,7 +235,7 @@ def __iter__(self) -> Iterator[str]:
yield from self.files

def upload(
self, path: str, data: Union[ByteString, BinaryIO, Iterable[ByteString]]
self, path: str, data: ByteString | BinaryIO | Iterable[ByteString]
) -> None:
"""
Uploads a file onto this bucket
Expand Down Expand Up @@ -326,7 +328,7 @@ def __iter__(self) -> Iterable[str]:
yield from self._bucket.files

def __setitem__(
self, key: str, value: Union[ByteString, BinaryIO, Iterable[ByteString]]
self, key: str, value: ByteString | BinaryIO | Iterable[ByteString]
) -> None:
"""
Uploads a file onto this bucket.
Expand Down Expand Up @@ -355,7 +357,7 @@ def __str__(self):
return f"MappedBucket<{self._bucket}>"


def _chunk_as_bytes(chunk: Union[int, ByteString]) -> ByteString:
def _chunk_as_bytes(chunk: int | ByteString) -> ByteString:
"""
In some scenarios python converts single bytes to integers:
>>> chunks = [type(chunk) for chunk in b"abc"]
Expand Down Expand Up @@ -403,7 +405,7 @@ def as_string(chunks: Iterable[ByteString], encoding: str = "utf-8") -> str:
return _bytes(chunks).decode(encoding)


def as_file(chunks: Iterable[ByteString], filename: Union[str, Path]) -> Path:
def as_file(chunks: Iterable[ByteString], filename: str | Path) -> Path:
"""
Transforms a set of byte chunks into a string.
Expand Down

0 comments on commit 952759e

Please sign in to comment.