Skip to content

Commit

Permalink
chore: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Feb 18, 2025
1 parent acbcb56 commit 3af73a3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/fsspec_httpx/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import asyncio
from collections.abc import Mapping
import contextlib
from copy import copy
import io
Expand Down Expand Up @@ -36,7 +35,7 @@


if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Callable, Mapping


# URL pattern in HTML href tags
Expand Down Expand Up @@ -103,10 +102,11 @@ def close_session(loop: Any, session: httpx.AsyncClient) -> None:
if loop is not None and loop.is_running():
try:
sync(loop, session.aclose, timeout=0.1)
return
except (TimeoutError, FSTimeoutError, NotImplementedError, RuntimeError):
# If we can't close it properly, just let it be garbage collected
pass
else:
return

async def set_session(self) -> httpx.AsyncClient:
if self._session is None:
Expand Down Expand Up @@ -182,7 +182,7 @@ async def _ls_real(self, url: str, detail: bool = True, **kwargs: Any) -> list |
or "[To Parent Directory]" in link
or (
link.startswith("/")
and os.path.dirname(base_path).rstrip("/") == link.rstrip("/")
and os.path.dirname(base_path).rstrip("/") == link.rstrip("/") # noqa
)
):
continue
Expand Down Expand Up @@ -276,15 +276,15 @@ async def _get_file(
callback.set_size(size)
self._raise_not_found_for_status(r, rpath)

outfile = lpath if isfilelike(lpath) else open(lpath, "wb")
outfile = lpath if isfilelike(lpath) else open(lpath, "wb") # type: ignore # noqa: PTH123, SIM115

try:
async for chunk in r.aiter_bytes(chunk_size):
outfile.write(chunk)
outfile.write(chunk) # type: ignore
callback.relative_update(len(chunk))
finally:
if not isfilelike(lpath):
outfile.close()
outfile.close() # type: ignore

async def _put_file(
self,
Expand All @@ -305,7 +305,7 @@ def gen_chunks():
context = nullcontext(lpath)
use_seek = False
else:
context = open(lpath, "rb") # noqa: SIM115
context = open(lpath, "rb") # noqa: PTH123, SIM115
use_seek = True

with context as f:
Expand Down

0 comments on commit 3af73a3

Please sign in to comment.