huggingface-hub 0.34.4__py3-none-any.whl → 1.0.0rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of huggingface-hub might be problematic. Click here for more details.

Files changed (125) hide show
  1. huggingface_hub/__init__.py +46 -45
  2. huggingface_hub/_commit_api.py +28 -28
  3. huggingface_hub/_commit_scheduler.py +11 -8
  4. huggingface_hub/_inference_endpoints.py +8 -8
  5. huggingface_hub/_jobs_api.py +167 -10
  6. huggingface_hub/_login.py +13 -39
  7. huggingface_hub/_oauth.py +8 -8
  8. huggingface_hub/_snapshot_download.py +14 -28
  9. huggingface_hub/_space_api.py +4 -4
  10. huggingface_hub/_tensorboard_logger.py +13 -14
  11. huggingface_hub/_upload_large_folder.py +15 -15
  12. huggingface_hub/_webhooks_payload.py +3 -3
  13. huggingface_hub/_webhooks_server.py +2 -2
  14. huggingface_hub/cli/_cli_utils.py +2 -2
  15. huggingface_hub/cli/auth.py +5 -6
  16. huggingface_hub/cli/cache.py +14 -20
  17. huggingface_hub/cli/download.py +4 -4
  18. huggingface_hub/cli/jobs.py +560 -11
  19. huggingface_hub/cli/lfs.py +4 -4
  20. huggingface_hub/cli/repo.py +7 -7
  21. huggingface_hub/cli/repo_files.py +2 -2
  22. huggingface_hub/cli/upload.py +4 -4
  23. huggingface_hub/cli/upload_large_folder.py +3 -3
  24. huggingface_hub/commands/_cli_utils.py +2 -2
  25. huggingface_hub/commands/delete_cache.py +13 -13
  26. huggingface_hub/commands/download.py +4 -13
  27. huggingface_hub/commands/lfs.py +4 -4
  28. huggingface_hub/commands/repo_files.py +2 -2
  29. huggingface_hub/commands/scan_cache.py +1 -1
  30. huggingface_hub/commands/tag.py +1 -3
  31. huggingface_hub/commands/upload.py +4 -4
  32. huggingface_hub/commands/upload_large_folder.py +3 -3
  33. huggingface_hub/commands/user.py +5 -6
  34. huggingface_hub/community.py +5 -5
  35. huggingface_hub/constants.py +3 -41
  36. huggingface_hub/dataclasses.py +16 -19
  37. huggingface_hub/errors.py +42 -29
  38. huggingface_hub/fastai_utils.py +8 -9
  39. huggingface_hub/file_download.py +153 -252
  40. huggingface_hub/hf_api.py +815 -600
  41. huggingface_hub/hf_file_system.py +98 -62
  42. huggingface_hub/hub_mixin.py +37 -57
  43. huggingface_hub/inference/_client.py +177 -325
  44. huggingface_hub/inference/_common.py +110 -124
  45. huggingface_hub/inference/_generated/_async_client.py +226 -432
  46. huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +3 -3
  47. huggingface_hub/inference/_generated/types/base.py +10 -7
  48. huggingface_hub/inference/_generated/types/chat_completion.py +18 -16
  49. huggingface_hub/inference/_generated/types/depth_estimation.py +2 -2
  50. huggingface_hub/inference/_generated/types/document_question_answering.py +2 -2
  51. huggingface_hub/inference/_generated/types/feature_extraction.py +2 -2
  52. huggingface_hub/inference/_generated/types/fill_mask.py +2 -2
  53. huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
  54. huggingface_hub/inference/_generated/types/summarization.py +2 -2
  55. huggingface_hub/inference/_generated/types/table_question_answering.py +4 -4
  56. huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
  57. huggingface_hub/inference/_generated/types/text_generation.py +10 -10
  58. huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
  59. huggingface_hub/inference/_generated/types/token_classification.py +2 -2
  60. huggingface_hub/inference/_generated/types/translation.py +2 -2
  61. huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
  62. huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
  63. huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
  64. huggingface_hub/inference/_mcp/_cli_hacks.py +3 -3
  65. huggingface_hub/inference/_mcp/agent.py +3 -3
  66. huggingface_hub/inference/_mcp/cli.py +1 -1
  67. huggingface_hub/inference/_mcp/constants.py +2 -3
  68. huggingface_hub/inference/_mcp/mcp_client.py +58 -30
  69. huggingface_hub/inference/_mcp/types.py +10 -7
  70. huggingface_hub/inference/_mcp/utils.py +11 -7
  71. huggingface_hub/inference/_providers/__init__.py +2 -2
  72. huggingface_hub/inference/_providers/_common.py +49 -25
  73. huggingface_hub/inference/_providers/black_forest_labs.py +6 -6
  74. huggingface_hub/inference/_providers/cohere.py +3 -3
  75. huggingface_hub/inference/_providers/fal_ai.py +25 -25
  76. huggingface_hub/inference/_providers/featherless_ai.py +4 -4
  77. huggingface_hub/inference/_providers/fireworks_ai.py +3 -3
  78. huggingface_hub/inference/_providers/hf_inference.py +28 -20
  79. huggingface_hub/inference/_providers/hyperbolic.py +4 -4
  80. huggingface_hub/inference/_providers/nebius.py +10 -10
  81. huggingface_hub/inference/_providers/novita.py +5 -5
  82. huggingface_hub/inference/_providers/nscale.py +4 -4
  83. huggingface_hub/inference/_providers/replicate.py +15 -15
  84. huggingface_hub/inference/_providers/sambanova.py +6 -6
  85. huggingface_hub/inference/_providers/together.py +7 -7
  86. huggingface_hub/lfs.py +20 -31
  87. huggingface_hub/repocard.py +18 -18
  88. huggingface_hub/repocard_data.py +56 -56
  89. huggingface_hub/serialization/__init__.py +0 -1
  90. huggingface_hub/serialization/_base.py +9 -9
  91. huggingface_hub/serialization/_dduf.py +7 -7
  92. huggingface_hub/serialization/_torch.py +28 -28
  93. huggingface_hub/utils/__init__.py +10 -4
  94. huggingface_hub/utils/_auth.py +5 -5
  95. huggingface_hub/utils/_cache_manager.py +31 -31
  96. huggingface_hub/utils/_deprecation.py +1 -1
  97. huggingface_hub/utils/_dotenv.py +3 -3
  98. huggingface_hub/utils/_fixes.py +0 -10
  99. huggingface_hub/utils/_git_credential.py +4 -4
  100. huggingface_hub/utils/_headers.py +7 -29
  101. huggingface_hub/utils/_http.py +366 -208
  102. huggingface_hub/utils/_pagination.py +4 -4
  103. huggingface_hub/utils/_paths.py +5 -5
  104. huggingface_hub/utils/_runtime.py +15 -13
  105. huggingface_hub/utils/_safetensors.py +21 -21
  106. huggingface_hub/utils/_subprocess.py +9 -9
  107. huggingface_hub/utils/_telemetry.py +3 -3
  108. huggingface_hub/utils/_typing.py +25 -5
  109. huggingface_hub/utils/_validators.py +53 -72
  110. huggingface_hub/utils/_xet.py +16 -16
  111. huggingface_hub/utils/_xet_progress_reporting.py +32 -11
  112. huggingface_hub/utils/insecure_hashlib.py +3 -9
  113. huggingface_hub/utils/tqdm.py +3 -3
  114. {huggingface_hub-0.34.4.dist-info → huggingface_hub-1.0.0rc0.dist-info}/METADATA +18 -29
  115. huggingface_hub-1.0.0rc0.dist-info/RECORD +161 -0
  116. huggingface_hub/inference_api.py +0 -217
  117. huggingface_hub/keras_mixin.py +0 -500
  118. huggingface_hub/repository.py +0 -1477
  119. huggingface_hub/serialization/_tensorflow.py +0 -95
  120. huggingface_hub/utils/_hf_folder.py +0 -68
  121. huggingface_hub-0.34.4.dist-info/RECORD +0 -166
  122. {huggingface_hub-0.34.4.dist-info → huggingface_hub-1.0.0rc0.dist-info}/LICENSE +0 -0
  123. {huggingface_hub-0.34.4.dist-info → huggingface_hub-1.0.0rc0.dist-info}/WHEEL +0 -0
  124. {huggingface_hub-0.34.4.dist-info → huggingface_hub-1.0.0rc0.dist-info}/entry_points.txt +0 -0
  125. {huggingface_hub-0.34.4.dist-info → huggingface_hub-1.0.0rc0.dist-info}/top_level.txt +0 -0
@@ -25,8 +25,6 @@ import argparse
25
25
  from argparse import _SubParsersAction
26
26
  from typing import Optional
27
27
 
28
- from requests.exceptions import HTTPError
29
-
30
28
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
31
29
  from huggingface_hub.commands._cli_utils import ANSI
32
30
  from huggingface_hub.constants import REPO_TYPES, SPACES_SDK_TYPES
@@ -183,7 +181,9 @@ class RepoTagCommand:
183
181
 
184
182
  class RepoTagCreateCommand(RepoTagCommand):
185
183
  def run(self):
186
- print(f"You are about to create tag {ANSI.bold(self.args.tag)} on {self.repo_type} {ANSI.bold(self.repo_id)}")
184
+ print(
185
+ f"You are about to create tag {ANSI.bold(str(self.args.tag))} on {self.repo_type} {ANSI.bold(self.repo_id)}"
186
+ )
187
187
  try:
188
188
  self.api.create_tag(
189
189
  repo_id=self.repo_id,
@@ -196,14 +196,14 @@ class RepoTagCreateCommand(RepoTagCommand):
196
196
  print(f"{self.repo_type.capitalize()} {ANSI.bold(self.repo_id)} not found.")
197
197
  exit(1)
198
198
  except RevisionNotFoundError:
199
- print(f"Revision {ANSI.bold(getattr(self.args, 'revision', None))} not found.")
199
+ print(f"Revision {ANSI.bold(str(getattr(self.args, 'revision', None)))} not found.")
200
200
  exit(1)
201
201
  except HfHubHTTPError as e:
202
202
  if e.response.status_code == 409:
203
- print(f"Tag {ANSI.bold(self.args.tag)} already exists on {ANSI.bold(self.repo_id)}")
203
+ print(f"Tag {ANSI.bold(str(self.args.tag))} already exists on {ANSI.bold(self.repo_id)}")
204
204
  exit(1)
205
205
  raise e
206
- print(f"Tag {ANSI.bold(self.args.tag)} created on {ANSI.bold(self.repo_id)}")
206
+ print(f"Tag {ANSI.bold(str(self.args.tag))} created on {ANSI.bold(self.repo_id)}")
207
207
 
208
208
 
209
209
  class RepoTagListCommand(RepoTagCommand):
@@ -216,7 +216,7 @@ class RepoTagListCommand(RepoTagCommand):
216
216
  except RepositoryNotFoundError:
217
217
  print(f"{self.repo_type.capitalize()} {ANSI.bold(self.repo_id)} not found.")
218
218
  exit(1)
219
- except HTTPError as e:
219
+ except HfHubHTTPError as e:
220
220
  print(e)
221
221
  print(ANSI.red(e.response.text))
222
222
  exit(1)
@@ -35,7 +35,7 @@ Usage:
35
35
  """
36
36
 
37
37
  from argparse import _SubParsersAction
38
- from typing import List, Optional
38
+ from typing import Optional
39
39
 
40
40
  from huggingface_hub import logging
41
41
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
@@ -52,7 +52,7 @@ class DeleteFilesSubCommand:
52
52
  self.repo_type: Optional[str] = args.repo_type
53
53
  self.revision: Optional[str] = args.revision
54
54
  self.api: HfApi = HfApi(token=args.token, library_name="hf")
55
- self.patterns: List[str] = args.patterns
55
+ self.patterns: list[str] = args.patterns
56
56
  self.commit_message: Optional[str] = args.commit_message
57
57
  self.commit_description: Optional[str] = args.commit_description
58
58
  self.create_pr: bool = args.create_pr
@@ -50,7 +50,7 @@ import os
50
50
  import time
51
51
  import warnings
52
52
  from argparse import Namespace, _SubParsersAction
53
- from typing import List, Optional
53
+ from typing import Optional
54
54
 
55
55
  from huggingface_hub import logging
56
56
  from huggingface_hub._commit_scheduler import CommitScheduler
@@ -144,9 +144,9 @@ class UploadCommand(BaseHuggingfaceCLICommand):
144
144
  self.revision: Optional[str] = args.revision
145
145
  self.private: bool = args.private
146
146
 
147
- self.include: Optional[List[str]] = args.include
148
- self.exclude: Optional[List[str]] = args.exclude
149
- self.delete: Optional[List[str]] = args.delete
147
+ self.include: Optional[list[str]] = args.include
148
+ self.exclude: Optional[list[str]] = args.exclude
149
+ self.delete: Optional[list[str]] = args.delete
150
150
 
151
151
  self.commit_message: Optional[str] = args.commit_message
152
152
  self.commit_description: Optional[str] = args.commit_description
@@ -16,7 +16,7 @@
16
16
 
17
17
  import os
18
18
  from argparse import Namespace, _SubParsersAction
19
- from typing import List, Optional
19
+ from typing import Optional
20
20
 
21
21
  from huggingface_hub import logging
22
22
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
@@ -76,8 +76,8 @@ class UploadLargeFolderCommand(BaseHuggingfaceCLICommand):
76
76
  self.revision: Optional[str] = args.revision
77
77
  self.private: bool = args.private
78
78
 
79
- self.include: Optional[List[str]] = args.include
80
- self.exclude: Optional[List[str]] = args.exclude
79
+ self.include: Optional[list[str]] = args.include
80
+ self.exclude: Optional[list[str]] = args.exclude
81
81
 
82
82
  self.api: HfApi = HfApi(token=args.token, library_name="hf")
83
83
 
@@ -14,7 +14,7 @@
14
14
  """Contains a utility for good-looking prints."""
15
15
 
16
16
  import os
17
- from typing import List, Union
17
+ from typing import Union
18
18
 
19
19
 
20
20
  class ANSI:
@@ -52,7 +52,7 @@ class ANSI:
52
52
  return f"{code}{s}{cls._reset}"
53
53
 
54
54
 
55
- def tabulate(rows: List[List[Union[str, int]]], headers: List[str]) -> str:
55
+ def tabulate(rows: list[list[Union[str, int]]], headers: list[str]) -> str:
56
56
  """
57
57
  Inspired by:
58
58
 
@@ -22,7 +22,7 @@ Usage:
22
22
 
23
23
  NOTE:
24
24
  This command is based on `InquirerPy` to build the multiselect menu in the terminal.
25
- This dependency has to be installed with `pip install huggingface_hub[cli]`. Since
25
+ This dependency has to be installed with `pip install "huggingface_hub[cli]"`. Since
26
26
  we want to avoid as much as possible cross-platform issues, I chose a library that
27
27
  is built on top of `python-prompt-toolkit` which seems to be a reference in terminal
28
28
  GUI (actively maintained on both Unix and Windows, 7.9k stars).
@@ -60,7 +60,7 @@ import os
60
60
  from argparse import Namespace, _SubParsersAction
61
61
  from functools import wraps
62
62
  from tempfile import mkstemp
63
- from typing import Any, Callable, Iterable, List, Literal, Optional, Union
63
+ from typing import Any, Callable, Iterable, Literal, Optional, Union
64
64
 
65
65
  from ..utils import CachedRepoInfo, CachedRevisionInfo, HFCacheInfo, scan_cache_dir
66
66
  from . import BaseHuggingfaceCLICommand
@@ -88,7 +88,7 @@ def require_inquirer_py(fn: Callable) -> Callable:
88
88
  if not _inquirer_py_available:
89
89
  raise ImportError(
90
90
  "The `delete-cache` command requires extra dependencies to work with"
91
- " the TUI.\nPlease run `pip install huggingface_hub[cli]` to install"
91
+ ' the TUI.\nPlease run `pip install "huggingface_hub[cli]"` to install'
92
92
  " them.\nOtherwise, disable TUI using the `--disable-tui` flag."
93
93
  )
94
94
 
@@ -197,9 +197,9 @@ def _get_repo_sorting_key(repo: CachedRepoInfo, sort_by: Optional[SortingOption_
197
197
  @require_inquirer_py
198
198
  def _manual_review_tui(
199
199
  hf_cache_info: HFCacheInfo,
200
- preselected: List[str],
200
+ preselected: list[str],
201
201
  sort_by: Optional[SortingOption_T] = None,
202
- ) -> List[str]:
202
+ ) -> list[str]:
203
203
  """Ask the user for a manual review of the revisions to delete.
204
204
 
205
205
  Displays a multi-select menu in the terminal (TUI).
@@ -254,15 +254,15 @@ def _ask_for_confirmation_tui(message: str, default: bool = True) -> bool:
254
254
 
255
255
  def _get_tui_choices_from_scan(
256
256
  repos: Iterable[CachedRepoInfo],
257
- preselected: List[str],
257
+ preselected: list[str],
258
258
  sort_by: Optional[SortingOption_T] = None,
259
- ) -> List:
259
+ ) -> list:
260
260
  """Build a list of choices from the scanned repos.
261
261
 
262
262
  Args:
263
263
  repos (*Iterable[`CachedRepoInfo`]*):
264
264
  List of scanned repos on which we want to delete revisions.
265
- preselected (*List[`str`]*):
265
+ preselected (*list[`str`]*):
266
266
  List of revision hashes that will be preselected.
267
267
  sort_by (*Optional[SortingOption_T]*):
268
268
  Sorting direction. Choices: "alphabetical", "lastUpdated", "lastUsed", "size".
@@ -270,7 +270,7 @@ def _get_tui_choices_from_scan(
270
270
  Return:
271
271
  The list of choices to pass to `inquirer.checkbox`.
272
272
  """
273
- choices: List[Union[Choice, Separator]] = []
273
+ choices: list[Union[Choice, Separator]] = []
274
274
 
275
275
  # First choice is to cancel the deletion
276
276
  choices.append(
@@ -312,9 +312,9 @@ def _get_tui_choices_from_scan(
312
312
 
313
313
  def _manual_review_no_tui(
314
314
  hf_cache_info: HFCacheInfo,
315
- preselected: List[str],
315
+ preselected: list[str],
316
316
  sort_by: Optional[SortingOption_T] = None,
317
- ) -> List[str]:
317
+ ) -> list[str]:
318
318
  """Ask the user for a manual review of the revisions to delete.
319
319
 
320
320
  Used when TUI is disabled. Manual review happens in a separate tmp file that the
@@ -390,7 +390,7 @@ def _ask_for_confirmation_no_tui(message: str, default: bool = True) -> bool:
390
390
  print(f"Invalid input. Must be one of {ALL}")
391
391
 
392
392
 
393
- def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]) -> str:
393
+ def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: list[str]) -> str:
394
394
  """Format a string to display to the user how much space would be saved.
395
395
 
396
396
  Example:
@@ -405,7 +405,7 @@ def _get_expectations_str(hf_cache_info: HFCacheInfo, selected_hashes: List[str]
405
405
  return f"{len(selected_hashes)} revisions selected counting for {strategy.expected_freed_size_str}."
406
406
 
407
407
 
408
- def _read_manual_review_tmp_file(tmp_path: str) -> List[str]:
408
+ def _read_manual_review_tmp_file(tmp_path: str) -> list[str]:
409
409
  """Read the manually reviewed instruction file and return a list of revision hash.
410
410
 
411
411
  Example:
@@ -38,7 +38,7 @@ Usage:
38
38
 
39
39
  import warnings
40
40
  from argparse import Namespace, _SubParsersAction
41
- from typing import List, Optional
41
+ from typing import Optional
42
42
 
43
43
  from huggingface_hub import logging
44
44
  from huggingface_hub._snapshot_download import snapshot_download
@@ -125,24 +125,17 @@ class DownloadCommand(BaseHuggingfaceCLICommand):
125
125
  def __init__(self, args: Namespace) -> None:
126
126
  self.token = args.token
127
127
  self.repo_id: str = args.repo_id
128
- self.filenames: List[str] = args.filenames
128
+ self.filenames: list[str] = args.filenames
129
129
  self.repo_type: str = args.repo_type
130
130
  self.revision: Optional[str] = args.revision
131
- self.include: Optional[List[str]] = args.include
132
- self.exclude: Optional[List[str]] = args.exclude
131
+ self.include: Optional[list[str]] = args.include
132
+ self.exclude: Optional[list[str]] = args.exclude
133
133
  self.cache_dir: Optional[str] = args.cache_dir
134
134
  self.local_dir: Optional[str] = args.local_dir
135
135
  self.force_download: bool = args.force_download
136
- self.resume_download: Optional[bool] = args.resume_download or None
137
136
  self.quiet: bool = args.quiet
138
137
  self.max_workers: int = args.max_workers
139
138
 
140
- if args.local_dir_use_symlinks is not None:
141
- warnings.warn(
142
- "Ignoring --local-dir-use-symlinks. Downloading to a local directory does not use symlinks anymore.",
143
- FutureWarning,
144
- )
145
-
146
139
  def run(self) -> None:
147
140
  show_deprecation_warning("huggingface-cli download", "hf download")
148
141
 
@@ -173,7 +166,6 @@ class DownloadCommand(BaseHuggingfaceCLICommand):
173
166
  revision=self.revision,
174
167
  filename=self.filenames[0],
175
168
  cache_dir=self.cache_dir,
176
- resume_download=self.resume_download,
177
169
  force_download=self.force_download,
178
170
  token=self.token,
179
171
  local_dir=self.local_dir,
@@ -194,7 +186,6 @@ class DownloadCommand(BaseHuggingfaceCLICommand):
194
186
  revision=self.revision,
195
187
  allow_patterns=allow_patterns,
196
188
  ignore_patterns=ignore_patterns,
197
- resume_download=self.resume_download,
198
189
  force_download=self.force_download,
199
190
  cache_dir=self.cache_dir,
200
191
  token=self.token,
@@ -21,7 +21,7 @@ import os
21
21
  import subprocess
22
22
  import sys
23
23
  from argparse import _SubParsersAction
24
- from typing import Dict, List, Optional
24
+ from typing import Optional
25
25
 
26
26
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
27
27
  from huggingface_hub.lfs import LFS_MULTIPART_UPLOAD_COMMAND
@@ -89,14 +89,14 @@ class LfsEnableCommand:
89
89
  print("Local repo set up for largefiles")
90
90
 
91
91
 
92
- def write_msg(msg: Dict):
92
+ def write_msg(msg: dict):
93
93
  """Write out the message in Line delimited JSON."""
94
94
  msg_str = json.dumps(msg) + "\n"
95
95
  sys.stdout.write(msg_str)
96
96
  sys.stdout.flush()
97
97
 
98
98
 
99
- def read_msg() -> Optional[Dict]:
99
+ def read_msg() -> Optional[dict]:
100
100
  """Read Line delimited JSON from stdin."""
101
101
  msg = json.loads(sys.stdin.readline().strip())
102
102
 
@@ -146,7 +146,7 @@ class LfsUploadCommand:
146
146
  completion_url = msg["action"]["href"]
147
147
  header = msg["action"]["header"]
148
148
  chunk_size = int(header.pop("chunk_size"))
149
- presigned_urls: List[str] = list(header.values())
149
+ presigned_urls: list[str] = list(header.values())
150
150
 
151
151
  # Send a "started" progress event to allow other workers to start.
152
152
  # Otherwise they're delayed until first "progress" event is reported,
@@ -35,7 +35,7 @@ Usage:
35
35
  """
36
36
 
37
37
  from argparse import _SubParsersAction
38
- from typing import List, Optional
38
+ from typing import Optional
39
39
 
40
40
  from huggingface_hub import logging
41
41
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
@@ -54,7 +54,7 @@ class DeleteFilesSubCommand:
54
54
  self.repo_type: Optional[str] = args.repo_type
55
55
  self.revision: Optional[str] = args.revision
56
56
  self.api: HfApi = HfApi(token=args.token, library_name="huggingface-cli")
57
- self.patterns: List[str] = args.patterns
57
+ self.patterns: list[str] = args.patterns
58
58
  self.commit_message: Optional[str] = args.commit_message
59
59
  self.commit_description: Optional[str] = args.commit_description
60
60
  self.create_pr: bool = args.create_pr
@@ -77,7 +77,7 @@ class ScanCacheCommand(BaseHuggingfaceCLICommand):
77
77
  if self.verbosity >= 3:
78
78
  print(ANSI.gray(message))
79
79
  for warning in hf_cache_info.warnings:
80
- print(ANSI.gray(warning))
80
+ print(ANSI.gray(str(warning)))
81
81
  else:
82
82
  print(ANSI.gray(message + " Use -vvv to print details."))
83
83
 
@@ -32,8 +32,6 @@ Usage Examples:
32
32
 
33
33
  from argparse import Namespace, _SubParsersAction
34
34
 
35
- from requests.exceptions import HTTPError
36
-
37
35
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
38
36
  from huggingface_hub.constants import (
39
37
  REPO_TYPES,
@@ -129,7 +127,7 @@ class TagListCommand(TagCommand):
129
127
  except RepositoryNotFoundError:
130
128
  print(f"{self.repo_type.capitalize()} {ANSI.bold(self.repo_id)} not found.")
131
129
  exit(1)
132
- except HTTPError as e:
130
+ except HfHubHTTPError as e:
133
131
  print(e)
134
132
  print(ANSI.red(e.response.text))
135
133
  exit(1)
@@ -50,7 +50,7 @@ import os
50
50
  import time
51
51
  import warnings
52
52
  from argparse import Namespace, _SubParsersAction
53
- from typing import List, Optional
53
+ from typing import Optional
54
54
 
55
55
  from huggingface_hub import logging
56
56
  from huggingface_hub._commit_scheduler import CommitScheduler
@@ -144,9 +144,9 @@ class UploadCommand(BaseHuggingfaceCLICommand):
144
144
  self.revision: Optional[str] = args.revision
145
145
  self.private: bool = args.private
146
146
 
147
- self.include: Optional[List[str]] = args.include
148
- self.exclude: Optional[List[str]] = args.exclude
149
- self.delete: Optional[List[str]] = args.delete
147
+ self.include: Optional[list[str]] = args.include
148
+ self.exclude: Optional[list[str]] = args.exclude
149
+ self.delete: Optional[list[str]] = args.delete
150
150
 
151
151
  self.commit_message: Optional[str] = args.commit_message
152
152
  self.commit_description: Optional[str] = args.commit_description
@@ -16,7 +16,7 @@
16
16
 
17
17
  import os
18
18
  from argparse import Namespace, _SubParsersAction
19
- from typing import List, Optional
19
+ from typing import Optional
20
20
 
21
21
  from huggingface_hub import logging
22
22
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
@@ -73,8 +73,8 @@ class UploadLargeFolderCommand(BaseHuggingfaceCLICommand):
73
73
  self.revision: Optional[str] = args.revision
74
74
  self.private: bool = args.private
75
75
 
76
- self.include: Optional[List[str]] = args.include
77
- self.exclude: Optional[List[str]] = args.exclude
76
+ self.include: Optional[list[str]] = args.include
77
+ self.exclude: Optional[list[str]] = args.exclude
78
78
 
79
79
  self.api: HfApi = HfApi(token=args.token, library_name="huggingface-cli")
80
80
 
@@ -31,12 +31,11 @@ Usage:
31
31
  """
32
32
 
33
33
  from argparse import _SubParsersAction
34
- from typing import List, Optional
35
-
36
- from requests.exceptions import HTTPError
34
+ from typing import Optional
37
35
 
38
36
  from huggingface_hub.commands import BaseHuggingfaceCLICommand
39
37
  from huggingface_hub.constants import ENDPOINT
38
+ from huggingface_hub.errors import HfHubHTTPError
40
39
  from huggingface_hub.hf_api import HfApi
41
40
 
42
41
  from .._login import auth_list, auth_switch, login, logout
@@ -164,7 +163,7 @@ class AuthSwitchCommand(BaseUserCommand):
164
163
  except ValueError:
165
164
  print("Invalid input. Please enter a number or 'q' to quit.")
166
165
 
167
- def _select_token_name_tui(self, token_names: List[str]) -> Optional[str]:
166
+ def _select_token_name_tui(self, token_names: list[str]) -> Optional[str]:
168
167
  choices = [Choice(token_name, name=token_name) for token_name in token_names]
169
168
  try:
170
169
  return inquirer.select(
@@ -195,14 +194,14 @@ class WhoamiCommand(BaseUserCommand):
195
194
  exit()
196
195
  try:
197
196
  info = self._api.whoami(token)
198
- print(ANSI.bold("user: "), info["name"])
197
+ print(info["name"])
199
198
  orgs = [org["name"] for org in info["orgs"]]
200
199
  if orgs:
201
200
  print(ANSI.bold("orgs: "), ",".join(orgs))
202
201
 
203
202
  if ENDPOINT != "https://huggingface.co":
204
203
  print(f"Authenticated through private endpoint: {ENDPOINT}")
205
- except HTTPError as e:
204
+ except HfHubHTTPError as e:
206
205
  print(e)
207
206
  print(ANSI.red(e.response.text))
208
207
  exit(1)
@@ -7,7 +7,7 @@ for more information on Pull Requests, Discussions, and the community tab.
7
7
 
8
8
  from dataclasses import dataclass
9
9
  from datetime import datetime
10
- from typing import List, Literal, Optional, Union
10
+ from typing import Literal, Optional, Union
11
11
 
12
12
  from . import constants
13
13
  from .utils import parse_datetime
@@ -116,7 +116,7 @@ class DiscussionWithDetails(Discussion):
116
116
  The `datetime` of creation of the Discussion / Pull Request.
117
117
  events (`list` of [`DiscussionEvent`])
118
118
  The list of [`DiscussionEvents`] in this Discussion or Pull Request.
119
- conflicting_files (`Union[List[str], bool, None]`, *optional*):
119
+ conflicting_files (`Union[list[str], bool, None]`, *optional*):
120
120
  A list of conflicting files if this is a Pull Request.
121
121
  `None` if `self.is_pull_request` is `False`.
122
122
  `True` if there are conflicting files but the list can't be retrieved.
@@ -136,8 +136,8 @@ class DiscussionWithDetails(Discussion):
136
136
  (property) URL of the discussion on the Hub.
137
137
  """
138
138
 
139
- events: List["DiscussionEvent"]
140
- conflicting_files: Union[List[str], bool, None]
139
+ events: list["DiscussionEvent"]
140
+ conflicting_files: Union[list[str], bool, None]
141
141
  target_branch: Optional[str]
142
142
  merge_commit_oid: Optional[str]
143
143
  diff: Optional[str]
@@ -222,7 +222,7 @@ class DiscussionComment(DiscussionEvent):
222
222
  return self._event["data"]["latest"].get("author", {}).get("name", "deleted")
223
223
 
224
224
  @property
225
- def edit_history(self) -> List[dict]:
225
+ def edit_history(self) -> list[dict]:
226
226
  """The edit history of the comment"""
227
227
  return self._event["data"]["history"]
228
228
 
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import re
3
3
  import typing
4
- from typing import Literal, Optional, Tuple
4
+ from typing import Literal, Optional
5
5
 
6
6
 
7
7
  # Possible values for env variables
@@ -118,9 +118,9 @@ REPO_TYPES_MAPPING = {
118
118
  }
119
119
 
120
120
  DiscussionTypeFilter = Literal["all", "discussion", "pull_request"]
121
- DISCUSSION_TYPES: Tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionTypeFilter)
121
+ DISCUSSION_TYPES: tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionTypeFilter)
122
122
  DiscussionStatusFilter = Literal["all", "open", "closed"]
123
- DISCUSSION_STATUS: Tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionStatusFilter)
123
+ DISCUSSION_STATUS: tuple[DiscussionTypeFilter, ...] = typing.get_args(DiscussionStatusFilter)
124
124
 
125
125
  # Webhook subscription types
126
126
  WEBHOOK_DOMAIN_T = Literal["repo", "discussions"]
@@ -135,7 +135,6 @@ HF_HOME = os.path.expandvars(
135
135
  )
136
136
  )
137
137
  )
138
- hf_cache_home = HF_HOME # for backward compatibility. TODO: remove this in 1.0.0
139
138
 
140
139
  default_cache_path = os.path.join(HF_HOME, "hub")
141
140
  default_assets_cache_path = os.path.join(HF_HOME, "assets")
@@ -234,43 +233,6 @@ HF_HUB_DOWNLOAD_TIMEOUT: int = _as_int(os.environ.get("HF_HUB_DOWNLOAD_TIMEOUT")
234
233
  # Allows to add information about the requester in the user-agent (eg. partner name)
235
234
  HF_HUB_USER_AGENT_ORIGIN: Optional[str] = os.environ.get("HF_HUB_USER_AGENT_ORIGIN")
236
235
 
237
- # List frameworks that are handled by the InferenceAPI service. Useful to scan endpoints and check which models are
238
- # deployed and running. Since 95% of the models are using the top 4 frameworks listed below, we scan only those by
239
- # default. We still keep the full list of supported frameworks in case we want to scan all of them.
240
- MAIN_INFERENCE_API_FRAMEWORKS = [
241
- "diffusers",
242
- "sentence-transformers",
243
- "text-generation-inference",
244
- "transformers",
245
- ]
246
-
247
- ALL_INFERENCE_API_FRAMEWORKS = MAIN_INFERENCE_API_FRAMEWORKS + [
248
- "adapter-transformers",
249
- "allennlp",
250
- "asteroid",
251
- "bertopic",
252
- "doctr",
253
- "espnet",
254
- "fairseq",
255
- "fastai",
256
- "fasttext",
257
- "flair",
258
- "k2",
259
- "keras",
260
- "mindspore",
261
- "nemo",
262
- "open_clip",
263
- "paddlenlp",
264
- "peft",
265
- "pyannote-audio",
266
- "sklearn",
267
- "spacy",
268
- "span-marker",
269
- "speechbrain",
270
- "stanza",
271
- "timm",
272
- ]
273
-
274
236
  # If OAuth didn't work after 2 redirects, there's likely a third-party cookie issue in the Space iframe view.
275
237
  # In this case, we redirect the user to the non-iframe view.
276
238
  OAUTH_MAX_REDIRECTS = 2