diff --git a/platform_storage_api/fs/local.py b/platform_storage_api/fs/local.py index 31325ba5..42e74612 100644 --- a/platform_storage_api/fs/local.py +++ b/platform_storage_api/fs/local.py @@ -363,22 +363,21 @@ async def _iterate_in_chunks( yield chunk def _scandir_iter(self, path: PurePath) -> Iterator[FileStatus]: - with self._resolve_dir_fd(path) as dirfd: - with os.scandir(dirfd) as scandir_it: - for entry in scandir_it: - if entry.is_symlink(): - target = os.readlink(entry.name, dir_fd=dirfd) - yield self._create_linkstatus( - PurePath(entry.name), - entry.stat(follow_symlinks=False), - target=target, - ) - else: - yield self._create_filestatus( - PurePath(entry.name), - entry.stat(follow_symlinks=False), - entry.is_dir(follow_symlinks=False), - ) + with self._resolve_dir_fd(path) as dirfd, os.scandir(dirfd) as scandir_it: + for entry in scandir_it: + if entry.is_symlink(): + target = os.readlink(entry.name, dir_fd=dirfd) + yield self._create_linkstatus( + PurePath(entry.name), + entry.stat(follow_symlinks=False), + target=target, + ) + else: + yield self._create_filestatus( + PurePath(entry.name), + entry.stat(follow_symlinks=False), + entry.is_dir(follow_symlinks=False), + ) async def _iterstatus_iter( self, dir_iter: Iterator[FileStatus] @@ -566,11 +565,11 @@ async def remove(self, path: PurePath, *, recursive: bool = False) -> None: await self._loop.run_in_executor(self._executor, self._remove, path, recursive) def _rename(self, old: PurePath, new: PurePath) -> None: - with self._resolve_dir_fd(old.parent) as src_dir_fd: - with self._resolve_dir_fd(new.parent) as dst_dir_fd: - os.rename( - old.name, new.name, src_dir_fd=src_dir_fd, dst_dir_fd=dst_dir_fd - ) + with ( + self._resolve_dir_fd(old.parent) as src_dir_fd, + self._resolve_dir_fd(new.parent) as dst_dir_fd, + ): + os.rename(old.name, new.name, src_dir_fd=src_dir_fd, dst_dir_fd=dst_dir_fd) async def rename(self, old: PurePath, new: PurePath) -> None: await self._loop.run_in_executor(self._executor, self._rename, old, new) diff --git a/platform_storage_api/storage.py b/platform_storage_api/storage.py index 06032d55..883ba3c0 100644 --- a/platform_storage_api/storage.py +++ b/platform_storage_api/storage.py @@ -189,7 +189,7 @@ async def rename( @trace async def disk_usage( - self, path: Optional[Union[PurePath, str]] = None + self, path: Union[PurePath, str, None] = None ) -> DiskUsageInfo: real_path = await self._path_resolver.resolve_path(PurePath(path or "/")) return await self._fs.disk_usage(real_path) diff --git a/tests/integration/auth.py b/tests/integration/auth.py index c233c01f..905561da 100644 --- a/tests/integration/auth.py +++ b/tests/integration/auth.py @@ -63,7 +63,6 @@ def _auth_server( auth_jwt_secret: str, _auth_url: URL, ) -> Iterator[URL]: - if _auth_url: yield _auth_url return diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index 42d76403..ba2a78ef 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -1031,7 +1031,6 @@ async def test_can_delete_folder_with_recursive_set( class TestGetFileStatus: - payload = b"test" len_payload = len(payload) file1 = "file1.txt" diff --git a/tests/integration/test_api_websocket.py b/tests/integration/test_api_websocket.py index b02fc202..7ce6fbd1 100644 --- a/tests/integration/test_api_websocket.py +++ b/tests/integration/test_api_websocket.py @@ -239,7 +239,6 @@ async def test_mkdirs( client: aiohttp.ClientSession, regular_user_factory: _UserFactory, ) -> None: - user = await regular_user_factory() headers = {"Authorization": "Bearer " + user.token} base_path = f"/{user.name}/root-{uuid.uuid4()}"