diff --git a/exasol/bucketfs/pathlike.py b/exasol/bucketfs/pathlike.py index 7336232c..af855c38 100644 --- a/exasol/bucketfs/pathlike.py +++ b/exasol/bucketfs/pathlike.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import Protocol, ByteString, BinaryIO, Iterable, Generator diff --git a/exasol/bucketfs/saas_file_api.py b/exasol/bucketfs/saas_file_api.py index d1bf897c..0ffb5d1c 100644 --- a/exasol/bucketfs/saas_file_api.py +++ b/exasol/bucketfs/saas_file_api.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import Protocol, Literal, Iterable, ByteString, BinaryIO from datetime import datetime diff --git a/exasol/bucketfs/saas_path.py b/exasol/bucketfs/saas_path.py index f7cf6447..b9854978 100644 --- a/exasol/bucketfs/saas_path.py +++ b/exasol/bucketfs/saas_path.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import ByteString, BinaryIO, Iterable, Optional, Generator from pathlib import PurePath import errno @@ -54,8 +55,7 @@ def _walk_node(node: SaasFile, path: Pathlike, top_down: bool) -> \ if node.children: for child in node.children: if not _is_file(child): - for paths, dirs, files in _walk_node(child, path / child.name, top_down): - yield paths, dirs, files + yield from _walk_node(child, path / child.name, top_down) if not top_down: yield path, dir_list, file_list @@ -146,7 +146,7 @@ def rm(self): current_node = self._navigate() if current_node is None: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(self._path)) - elif not _is_file(current_node): + if not _is_file(current_node): raise IsADirectoryError(errno.EISDIR, os.strerror(errno.EISDIR), str(self._path)) self._saas_file_api.delete_file(str(self._path)) @@ -154,9 +154,9 @@ def rmdir(self, recursive: bool = False): current_node = self._navigate() if current_node is None: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(self._path)) - elif _is_file(current_node): + if _is_file(current_node): raise NotADirectoryError(errno.ENOTDIR, os.strerror(errno.ENOTDIR), str(self._path)) - elif not current_node.children: + if not current_node.children: self._saas_file_api.delete_folder(str(self._path)) elif recursive: self._rmdir_recursive(current_node) @@ -185,8 +185,7 @@ def walk(self, top_down: bool = True) -> Generator[tuple[Pathlike, list[str], li raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(self._path)) if not _is_file(current_node): - for output in _walk_node(current_node, self, top_down): - yield output + yield from _walk_node(current_node, self, top_down) def iterdir(self) -> Generator[Pathlike, None, None]: current_node = self._navigate() diff --git a/test/unit/saas_file_mock.py b/test/unit/saas_file_mock.py index aa7cfe04..0ab136c2 100644 --- a/test/unit/saas_file_mock.py +++ b/test/unit/saas_file_mock.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import Iterable, ByteString, BinaryIO from datetime import datetime import os diff --git a/test/unit/test_saas_path.py b/test/unit/test_saas_path.py index d9de0d16..620c3a48 100644 --- a/test/unit/test_saas_path.py +++ b/test/unit/test_saas_path.py @@ -1,6 +1,6 @@ from pathlib import Path -import pytest from itertools import chain +import pytest from exasol.bucketfs.saas_path import SaaSBucketPath from test.unit.saas_file_mock import SaasFileApiMock