1111from dataclasses import dataclass , field
1212from itertools import groupby
1313from pathlib import Path , PurePosixPath
14- from typing import TYPE_CHECKING , Any , BinaryIO , Dict , Iterable , Iterator , List , Literal , Optional , Tuple , Union
14+ from typing import TYPE_CHECKING , Any , BinaryIO , Dict , Iterable , Iterator , Literal , Optional , Union
1515
1616from tqdm .contrib .concurrent import thread_map
1717
@@ -306,7 +306,7 @@ def _validate_path_in_repo(path_in_repo: str) -> str:
306306CommitOperation = Union [CommitOperationAdd , CommitOperationCopy , CommitOperationDelete ]
307307
308308
309- def _warn_on_overwriting_operations (operations : List [CommitOperation ]) -> None :
309+ def _warn_on_overwriting_operations (operations : list [CommitOperation ]) -> None :
310310 """
311311 Warn user when a list of operations is expected to overwrite itself in a single
312312 commit.
@@ -321,7 +321,7 @@ def _warn_on_overwriting_operations(operations: List[CommitOperation]) -> None:
321321 delete before upload) but can happen if a user deletes an entire folder and then
322322 add new files to it.
323323 """
324- nb_additions_per_path : Dict [str , int ] = defaultdict (int )
324+ nb_additions_per_path : dict [str , int ] = defaultdict (int )
325325 for operation in operations :
326326 path_in_repo = operation .path_in_repo
327327 if isinstance (operation , CommitOperationAdd ):
@@ -355,10 +355,10 @@ def _warn_on_overwriting_operations(operations: List[CommitOperation]) -> None:
355355@validate_hf_hub_args
356356def _upload_lfs_files (
357357 * ,
358- additions : List [CommitOperationAdd ],
358+ additions : list [CommitOperationAdd ],
359359 repo_type : str ,
360360 repo_id : str ,
361- headers : Dict [str , str ],
361+ headers : dict [str , str ],
362362 endpoint : Optional [str ] = None ,
363363 num_threads : int = 5 ,
364364 revision : Optional [str ] = None ,
@@ -377,7 +377,7 @@ def _upload_lfs_files(
377377 repo_id (`str`):
378378 A namespace (user or an organization) and a repo name separated
379379 by a `/`.
380- headers (`Dict [str, str]`):
380+ headers (`dict [str, str]`):
381381 Headers to use for the request, including authorization headers and user agent.
382382 num_threads (`int`, *optional*):
383383 The number of concurrent threads to use when uploading. Defaults to 5.
@@ -395,7 +395,7 @@ def _upload_lfs_files(
395395 # Step 1: retrieve upload instructions from the LFS batch endpoint.
396396 # Upload instructions are retrieved by chunk of 256 files to avoid reaching
397397 # the payload limit.
398- batch_actions : List [Dict ] = []
398+ batch_actions : list [Dict ] = []
399399 for chunk in chunk_iterable (additions , chunk_size = UPLOAD_BATCH_MAX_NUM_FILES ):
400400 batch_actions_chunk , batch_errors_chunk = post_lfs_batch_info (
401401 upload_infos = [op .upload_info for op in chunk ],
@@ -466,10 +466,10 @@ def _wrapped_lfs_upload(batch_action) -> None:
466466@validate_hf_hub_args
467467def _upload_xet_files (
468468 * ,
469- additions : List [CommitOperationAdd ],
469+ additions : list [CommitOperationAdd ],
470470 repo_type : str ,
471471 repo_id : str ,
472- headers : Dict [str , str ],
472+ headers : dict [str , str ],
473473 endpoint : Optional [str ] = None ,
474474 revision : Optional [str ] = None ,
475475 create_pr : Optional [bool ] = None ,
@@ -486,7 +486,7 @@ def _upload_xet_files(
486486 repo_id (`str`):
487487 A namespace (user or an organization) and a repo name separated
488488 by a `/`.
489- headers (`Dict [str, str]`):
489+ headers (`dict [str, str]`):
490490 Headers to use for the request, including authorization headers and user agent.
491491 endpoint: (`str`, *optional*):
492492 The endpoint to use for the xetcas service. Defaults to `constants.ENDPOINT`.
@@ -555,7 +555,7 @@ def _upload_xet_files(
555555 xet_endpoint = xet_connection_info .endpoint
556556 access_token_info = (xet_connection_info .access_token , xet_connection_info .expiration_unix_epoch )
557557
558- def token_refresher () -> Tuple [str , int ]:
558+ def token_refresher () -> tuple [str , int ]:
559559 new_xet_connection = fetch_xet_connection_info_from_repo_info (
560560 token_type = XetTokenType .WRITE ,
561561 repo_id = repo_id ,
@@ -628,7 +628,7 @@ def _fetch_upload_modes(
628628 additions : Iterable [CommitOperationAdd ],
629629 repo_type : str ,
630630 repo_id : str ,
631- headers : Dict [str , str ],
631+ headers : dict [str , str ],
632632 revision : str ,
633633 endpoint : Optional [str ] = None ,
634634 create_pr : bool = False ,
@@ -647,7 +647,7 @@ def _fetch_upload_modes(
647647 repo_id (`str`):
648648 A namespace (user or an organization) and a repo name separated
649649 by a `/`.
650- headers (`Dict [str, str]`):
650+ headers (`dict [str, str]`):
651651 Headers to use for the request, including authorization headers and user agent.
652652 revision (`str`):
653653 The git revision to upload the files to. Can be any valid git revision.
@@ -665,9 +665,9 @@ def _fetch_upload_modes(
665665 endpoint = endpoint if endpoint is not None else constants .ENDPOINT
666666
667667 # Fetch upload mode (LFS or regular) chunk by chunk.
668- upload_modes : Dict [str , UploadMode ] = {}
669- should_ignore_info : Dict [str , bool ] = {}
670- oid_info : Dict [str , Optional [str ]] = {}
668+ upload_modes : dict [str , UploadMode ] = {}
669+ should_ignore_info : dict [str , bool ] = {}
670+ oid_info : dict [str , Optional [str ]] = {}
671671
672672 for chunk in chunk_iterable (additions , 256 ):
673673 payload : Dict = {
@@ -713,10 +713,10 @@ def _fetch_files_to_copy(
713713 copies : Iterable [CommitOperationCopy ],
714714 repo_type : str ,
715715 repo_id : str ,
716- headers : Dict [str , str ],
716+ headers : dict [str , str ],
717717 revision : str ,
718718 endpoint : Optional [str ] = None ,
719- ) -> Dict [ Tuple [str , Optional [str ]], Union ["RepoFile" , bytes ]]:
719+ ) -> dict [ tuple [str , Optional [str ]], Union ["RepoFile" , bytes ]]:
720720 """
721721 Fetch information about the files to copy.
722722
@@ -732,12 +732,12 @@ def _fetch_files_to_copy(
732732 repo_id (`str`):
733733 A namespace (user or an organization) and a repo name separated
734734 by a `/`.
735- headers (`Dict [str, str]`):
735+ headers (`dict [str, str]`):
736736 Headers to use for the request, including authorization headers and user agent.
737737 revision (`str`):
738738 The git revision to upload the files to. Can be any valid git revision.
739739
740- Returns: `Dict[Tuple [str, Optional[str]], Union[RepoFile, bytes]]]`
740+ Returns: `dict[tuple [str, Optional[str]], Union[RepoFile, bytes]]]`
741741 Key is the file path and revision of the file to copy.
742742 Value is the raw content as bytes (for regular files) or the file information as a RepoFile (for LFS files).
743743
@@ -750,9 +750,9 @@ def _fetch_files_to_copy(
750750 from .hf_api import HfApi , RepoFolder
751751
752752 hf_api = HfApi (endpoint = endpoint , headers = headers )
753- files_to_copy : Dict [ Tuple [str , Optional [str ]], Union ["RepoFile" , bytes ]] = {}
753+ files_to_copy : dict [ tuple [str , Optional [str ]], Union ["RepoFile" , bytes ]] = {}
754754 # Store (path, revision) -> oid mapping
755- oid_info : Dict [ Tuple [str , Optional [str ]], Optional [str ]] = {}
755+ oid_info : dict [ tuple [str , Optional [str ]], Optional [str ]] = {}
756756 # 1. Fetch OIDs for destination paths in batches.
757757 dest_paths = [op .path_in_repo for op in copies ]
758758 for offset in range (0 , len (dest_paths ), FETCH_LFS_BATCH_SIZE ):
@@ -812,11 +812,11 @@ def _fetch_files_to_copy(
812812
813813def _prepare_commit_payload (
814814 operations : Iterable [CommitOperation ],
815- files_to_copy : Dict [ Tuple [str , Optional [str ]], Union ["RepoFile" , bytes ]],
815+ files_to_copy : dict [ tuple [str , Optional [str ]], Union ["RepoFile" , bytes ]],
816816 commit_message : str ,
817817 commit_description : Optional [str ] = None ,
818818 parent_commit : Optional [str ] = None ,
819- ) -> Iterable [Dict [str , Any ]]:
819+ ) -> Iterable [dict [str , Any ]]:
820820 """
821821 Builds the payload to POST to the `/commit` API of the Hub.
822822
0 commit comments