Skip to content

Commit

Permalink
fix type errors in url_operations.file
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-monch committed Mar 27, 2024
1 parent 5053224 commit 0c248eb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions datalad_next/url_operations/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
import logging
import random
import sys
from io import IOBase
from pathlib import Path
from typing import Dict
from typing import (
BinaryIO,
Dict,
)
from urllib import (
request,
parse,
Expand Down Expand Up @@ -161,7 +165,9 @@ def upload(self,
to_path = self._file_url_to_path(to_url)
if atomic:
final_path = to_path
to_path = to_path.with_suffix(
# added a `nosec` below because we don't need a cryptographically
# secure random number here.
to_path = to_path.with_suffix( # nosec
to_path.suffix
+ f'.transfer-{random.randint(1000000000, 9999999999)}'
)
Expand Down Expand Up @@ -229,9 +235,9 @@ def delete(self,
raise UrlOperationsRemoteError(url, message=str(e)) from e

def _copyfp(self,
src_fp: file,
dst_fp: file,
expected_size: int,
src_fp: IOBase | BinaryIO,
dst_fp: IOBase | BinaryIO,
expected_size: int | None,
hash: list[str] | None,
start_log: tuple,
update_log: tuple,
Expand All @@ -241,7 +247,7 @@ def _copyfp(self,
# this is pretty much shutil.copyfileobj() with the necessary
# wrapping to perform hashing and progress reporting
hasher = self._get_hasher(hash)
progress_id = self._get_progress_id(id(src_fp), id(src_fp))
progress_id = self._get_progress_id(str(id(src_fp)), str(id(dst_fp)))

# Localize variable access to minimize overhead
src_fp_read = src_fp.read
Expand Down

0 comments on commit 0c248eb

Please sign in to comment.