huggingface-hub 0.35.1__py3-none-any.whl → 1.0.0rc1__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 (127) hide show
  1. huggingface_hub/__init__.py +28 -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 +20 -20
  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 +5 -5
  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/__init__.py +0 -14
  15. huggingface_hub/cli/_cli_utils.py +80 -3
  16. huggingface_hub/cli/auth.py +104 -150
  17. huggingface_hub/cli/cache.py +102 -126
  18. huggingface_hub/cli/download.py +93 -110
  19. huggingface_hub/cli/hf.py +37 -41
  20. huggingface_hub/cli/jobs.py +689 -1017
  21. huggingface_hub/cli/lfs.py +120 -143
  22. huggingface_hub/cli/repo.py +158 -216
  23. huggingface_hub/cli/repo_files.py +50 -84
  24. huggingface_hub/cli/system.py +6 -25
  25. huggingface_hub/cli/upload.py +198 -212
  26. huggingface_hub/cli/upload_large_folder.py +90 -105
  27. huggingface_hub/commands/_cli_utils.py +2 -2
  28. huggingface_hub/commands/delete_cache.py +11 -11
  29. huggingface_hub/commands/download.py +4 -13
  30. huggingface_hub/commands/lfs.py +4 -4
  31. huggingface_hub/commands/repo_files.py +2 -2
  32. huggingface_hub/commands/tag.py +1 -3
  33. huggingface_hub/commands/upload.py +4 -4
  34. huggingface_hub/commands/upload_large_folder.py +3 -3
  35. huggingface_hub/commands/user.py +4 -5
  36. huggingface_hub/community.py +5 -5
  37. huggingface_hub/constants.py +3 -41
  38. huggingface_hub/dataclasses.py +16 -22
  39. huggingface_hub/errors.py +43 -30
  40. huggingface_hub/fastai_utils.py +8 -9
  41. huggingface_hub/file_download.py +154 -253
  42. huggingface_hub/hf_api.py +329 -558
  43. huggingface_hub/hf_file_system.py +104 -62
  44. huggingface_hub/hub_mixin.py +32 -54
  45. huggingface_hub/inference/_client.py +178 -163
  46. huggingface_hub/inference/_common.py +38 -54
  47. huggingface_hub/inference/_generated/_async_client.py +219 -259
  48. huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +3 -3
  49. huggingface_hub/inference/_generated/types/base.py +10 -7
  50. huggingface_hub/inference/_generated/types/chat_completion.py +16 -16
  51. huggingface_hub/inference/_generated/types/depth_estimation.py +2 -2
  52. huggingface_hub/inference/_generated/types/document_question_answering.py +2 -2
  53. huggingface_hub/inference/_generated/types/feature_extraction.py +2 -2
  54. huggingface_hub/inference/_generated/types/fill_mask.py +2 -2
  55. huggingface_hub/inference/_generated/types/sentence_similarity.py +3 -3
  56. huggingface_hub/inference/_generated/types/summarization.py +2 -2
  57. huggingface_hub/inference/_generated/types/table_question_answering.py +4 -4
  58. huggingface_hub/inference/_generated/types/text2text_generation.py +2 -2
  59. huggingface_hub/inference/_generated/types/text_generation.py +10 -10
  60. huggingface_hub/inference/_generated/types/text_to_video.py +2 -2
  61. huggingface_hub/inference/_generated/types/token_classification.py +2 -2
  62. huggingface_hub/inference/_generated/types/translation.py +2 -2
  63. huggingface_hub/inference/_generated/types/zero_shot_classification.py +2 -2
  64. huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +2 -2
  65. huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +1 -3
  66. huggingface_hub/inference/_mcp/agent.py +3 -3
  67. huggingface_hub/inference/_mcp/constants.py +1 -2
  68. huggingface_hub/inference/_mcp/mcp_client.py +33 -22
  69. huggingface_hub/inference/_mcp/types.py +10 -10
  70. huggingface_hub/inference/_mcp/utils.py +4 -4
  71. huggingface_hub/inference/_providers/__init__.py +2 -13
  72. huggingface_hub/inference/_providers/_common.py +24 -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 +13 -13
  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 +24 -33
  87. huggingface_hub/repocard.py +16 -17
  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 +3 -3
  100. huggingface_hub/utils/_headers.py +7 -29
  101. huggingface_hub/utils/_http.py +369 -209
  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 +3 -3
  109. huggingface_hub/utils/_validators.py +53 -72
  110. huggingface_hub/utils/_xet.py +16 -16
  111. huggingface_hub/utils/_xet_progress_reporting.py +1 -1
  112. huggingface_hub/utils/insecure_hashlib.py +3 -9
  113. huggingface_hub/utils/tqdm.py +3 -3
  114. {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/METADATA +17 -26
  115. huggingface_hub-1.0.0rc1.dist-info/RECORD +161 -0
  116. huggingface_hub/inference/_providers/publicai.py +0 -6
  117. huggingface_hub/inference/_providers/scaleway.py +0 -28
  118. huggingface_hub/inference_api.py +0 -217
  119. huggingface_hub/keras_mixin.py +0 -500
  120. huggingface_hub/repository.py +0 -1477
  121. huggingface_hub/serialization/_tensorflow.py +0 -95
  122. huggingface_hub/utils/_hf_folder.py +0 -68
  123. huggingface_hub-0.35.1.dist-info/RECORD +0 -168
  124. {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/LICENSE +0 -0
  125. {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/WHEEL +0 -0
  126. {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/entry_points.txt +0 -0
  127. {huggingface_hub-0.35.1.dist-info → huggingface_hub-1.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -4,12 +4,8 @@ from functools import wraps
4
4
  from typing import (
5
5
  Any,
6
6
  Callable,
7
- Dict,
8
- ForwardRef,
9
- List,
10
7
  Literal,
11
8
  Optional,
12
- Tuple,
13
9
  Type,
14
10
  TypeVar,
15
11
  Union,
@@ -103,7 +99,7 @@ def strict(
103
99
  )
104
100
 
105
101
  # List and store validators
106
- field_validators: Dict[str, List[Validator_T]] = {}
102
+ field_validators: dict[str, list[Validator_T]] = {}
107
103
  for f in fields(cls): # type: ignore [arg-type]
108
104
  validators = []
109
105
  validators.append(_create_type_validator(f))
@@ -239,14 +235,14 @@ def strict(
239
235
 
240
236
 
241
237
  def validated_field(
242
- validator: Union[List[Validator_T], Validator_T],
238
+ validator: Union[list[Validator_T], Validator_T],
243
239
  default: Union[Any, _MISSING_TYPE] = MISSING,
244
240
  default_factory: Union[Callable[[], Any], _MISSING_TYPE] = MISSING,
245
241
  init: bool = True,
246
242
  repr: bool = True,
247
243
  hash: Optional[bool] = None,
248
244
  compare: bool = True,
249
- metadata: Optional[Dict] = None,
245
+ metadata: Optional[dict] = None,
250
246
  **kwargs: Any,
251
247
  ) -> Any:
252
248
  """
@@ -255,7 +251,7 @@ def validated_field(
255
251
  Useful to apply several checks to a field. If only applying one rule, check out the [`as_validated_field`] decorator.
256
252
 
257
253
  Args:
258
- validator (`Callable` or `List[Callable]`):
254
+ validator (`Callable` or `list[Callable]`):
259
255
  A method that takes a value as input and raises ValueError/TypeError if the value is invalid.
260
256
  Can be a list of validators to apply multiple checks.
261
257
  **kwargs:
@@ -297,7 +293,7 @@ def as_validated_field(validator: Validator_T):
297
293
  repr: bool = True,
298
294
  hash: Optional[bool] = None,
299
295
  compare: bool = True,
300
- metadata: Optional[Dict] = None,
296
+ metadata: Optional[dict] = None,
301
297
  **kwargs: Any,
302
298
  ):
303
299
  return validated_field(
@@ -326,13 +322,11 @@ def type_validator(name: str, value: Any, expected_type: Any) -> None:
326
322
  validator(name, value, args)
327
323
  elif isinstance(expected_type, type): # simple types
328
324
  _validate_simple_type(name, value, expected_type)
329
- elif isinstance(expected_type, ForwardRef) or isinstance(expected_type, str):
330
- return
331
325
  else:
332
326
  raise TypeError(f"Unsupported type for field '{name}': {expected_type}")
333
327
 
334
328
 
335
- def _validate_union(name: str, value: Any, args: Tuple[Any, ...]) -> None:
329
+ def _validate_union(name: str, value: Any, args: tuple[Any, ...]) -> None:
336
330
  """Validate that value matches one of the types in a Union."""
337
331
  errors = []
338
332
  for t in args:
@@ -347,14 +341,14 @@ def _validate_union(name: str, value: Any, args: Tuple[Any, ...]) -> None:
347
341
  )
348
342
 
349
343
 
350
- def _validate_literal(name: str, value: Any, args: Tuple[Any, ...]) -> None:
344
+ def _validate_literal(name: str, value: Any, args: tuple[Any, ...]) -> None:
351
345
  """Validate Literal type."""
352
346
  if value not in args:
353
347
  raise TypeError(f"Field '{name}' expected one of {args}, got {value}")
354
348
 
355
349
 
356
- def _validate_list(name: str, value: Any, args: Tuple[Any, ...]) -> None:
357
- """Validate List[T] type."""
350
+ def _validate_list(name: str, value: Any, args: tuple[Any, ...]) -> None:
351
+ """Validate list[T] type."""
358
352
  if not isinstance(value, list):
359
353
  raise TypeError(f"Field '{name}' expected a list, got {type(value).__name__}")
360
354
 
@@ -367,8 +361,8 @@ def _validate_list(name: str, value: Any, args: Tuple[Any, ...]) -> None:
367
361
  raise TypeError(f"Invalid item at index {i} in list '{name}'") from e
368
362
 
369
363
 
370
- def _validate_dict(name: str, value: Any, args: Tuple[Any, ...]) -> None:
371
- """Validate Dict[K, V] type."""
364
+ def _validate_dict(name: str, value: Any, args: tuple[Any, ...]) -> None:
365
+ """Validate dict[K, V] type."""
372
366
  if not isinstance(value, dict):
373
367
  raise TypeError(f"Field '{name}' expected a dict, got {type(value).__name__}")
374
368
 
@@ -382,19 +376,19 @@ def _validate_dict(name: str, value: Any, args: Tuple[Any, ...]) -> None:
382
376
  raise TypeError(f"Invalid key or value in dict '{name}'") from e
383
377
 
384
378
 
385
- def _validate_tuple(name: str, value: Any, args: Tuple[Any, ...]) -> None:
379
+ def _validate_tuple(name: str, value: Any, args: tuple[Any, ...]) -> None:
386
380
  """Validate Tuple type."""
387
381
  if not isinstance(value, tuple):
388
382
  raise TypeError(f"Field '{name}' expected a tuple, got {type(value).__name__}")
389
383
 
390
- # Handle variable-length tuples: Tuple[T, ...]
384
+ # Handle variable-length tuples: tuple[T, ...]
391
385
  if len(args) == 2 and args[1] is Ellipsis:
392
386
  for i, item in enumerate(value):
393
387
  try:
394
388
  type_validator(f"{name}[{i}]", item, args[0])
395
389
  except TypeError as e:
396
390
  raise TypeError(f"Invalid item at index {i} in tuple '{name}'") from e
397
- # Handle fixed-length tuples: Tuple[T1, T2, ...]
391
+ # Handle fixed-length tuples: tuple[T1, T2, ...]
398
392
  elif len(args) != len(value):
399
393
  raise TypeError(f"Field '{name}' expected a tuple of length {len(args)}, got {len(value)}")
400
394
  else:
@@ -405,8 +399,8 @@ def _validate_tuple(name: str, value: Any, args: Tuple[Any, ...]) -> None:
405
399
  raise TypeError(f"Invalid item at index {i} in tuple '{name}'") from e
406
400
 
407
401
 
408
- def _validate_set(name: str, value: Any, args: Tuple[Any, ...]) -> None:
409
- """Validate Set[T] type."""
402
+ def _validate_set(name: str, value: Any, args: tuple[Any, ...]) -> None:
403
+ """Validate set[T] type."""
410
404
  if not isinstance(value, set):
411
405
  raise TypeError(f"Field '{name}' expected a set, got {type(value).__name__}")
412
406
 
huggingface_hub/errors.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from pathlib import Path
4
4
  from typing import Optional, Union
5
5
 
6
- from requests import HTTPError, Response
6
+ from httpx import HTTPError, Response
7
7
 
8
8
 
9
9
  # CACHE ERRORS
@@ -37,7 +37,7 @@ class OfflineModeIsEnabled(ConnectionError):
37
37
  """Raised when a request is made but `HF_HUB_OFFLINE=1` is set as environment variable."""
38
38
 
39
39
 
40
- class HfHubHTTPError(HTTPError):
40
+ class HfHubHTTPError(HTTPError, OSError):
41
41
  """
42
42
  HTTPError to inherit from for any custom HTTP Error raised in HF Hub.
43
43
 
@@ -51,7 +51,7 @@ class HfHubHTTPError(HTTPError):
51
51
 
52
52
  Example:
53
53
  ```py
54
- import requests
54
+ import httpx
55
55
  from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
56
56
 
57
57
  response = get_session().post(...)
@@ -67,19 +67,18 @@ class HfHubHTTPError(HTTPError):
67
67
  ```
68
68
  """
69
69
 
70
- def __init__(self, message: str, response: Optional[Response] = None, *, server_message: Optional[str] = None):
71
- self.request_id = (
72
- response.headers.get("x-request-id") or response.headers.get("X-Amzn-Trace-Id")
73
- if response is not None
74
- else None
75
- )
70
+ def __init__(
71
+ self,
72
+ message: str,
73
+ *,
74
+ response: Response,
75
+ server_message: Optional[str] = None,
76
+ ):
77
+ self.request_id = response.headers.get("x-request-id") or response.headers.get("X-Amzn-Trace-Id")
76
78
  self.server_message = server_message
77
-
78
- super().__init__(
79
- message,
80
- response=response, # type: ignore [arg-type]
81
- request=response.request if response is not None else None, # type: ignore [arg-type]
82
- )
79
+ self.response = response
80
+ self.request = response.request
81
+ super().__init__(message)
83
82
 
84
83
  def append_to_message(self, additional_message: str) -> None:
85
84
  """Append additional information to the `HfHubHTTPError` initial message."""
@@ -182,7 +181,7 @@ class RepositoryNotFoundError(HfHubHTTPError):
182
181
  >>> from huggingface_hub import model_info
183
182
  >>> model_info("<non_existent_repository>")
184
183
  (...)
185
- huggingface_hub.utils._errors.RepositoryNotFoundError: 401 Client Error. (Request ID: PvMw_VjBMjVdMz53WKIzP)
184
+ huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: PvMw_VjBMjVdMz53WKIzP)
186
185
 
187
186
  Repository Not Found for url: https://huggingface.co/api/models/%3Cnon_existent_repository%3E.
188
187
  Please make sure you specified the correct `repo_id` and `repo_type`.
@@ -205,7 +204,7 @@ class GatedRepoError(RepositoryNotFoundError):
205
204
  >>> from huggingface_hub import model_info
206
205
  >>> model_info("<gated_repository>")
207
206
  (...)
208
- huggingface_hub.utils._errors.GatedRepoError: 403 Client Error. (Request ID: ViT1Bf7O_026LGSQuVqfa)
207
+ huggingface_hub.errors.GatedRepoError: 403 Client Error. (Request ID: ViT1Bf7O_026LGSQuVqfa)
209
208
 
210
209
  Cannot access gated repo for url https://huggingface.co/api/models/ardent-figment/gated-model.
211
210
  Access to model ardent-figment/gated-model is restricted and you are not in the authorized list.
@@ -224,7 +223,7 @@ class DisabledRepoError(HfHubHTTPError):
224
223
  >>> from huggingface_hub import dataset_info
225
224
  >>> dataset_info("laion/laion-art")
226
225
  (...)
227
- huggingface_hub.utils._errors.DisabledRepoError: 403 Client Error. (Request ID: Root=1-659fc3fa-3031673e0f92c71a2260dbe2;bc6f4dfb-b30a-4862-af0a-5cfe827610d8)
226
+ huggingface_hub.errors.DisabledRepoError: 403 Client Error. (Request ID: Root=1-659fc3fa-3031673e0f92c71a2260dbe2;bc6f4dfb-b30a-4862-af0a-5cfe827610d8)
228
227
 
229
228
  Cannot access repository for url https://huggingface.co/api/datasets/laion/laion-art.
230
229
  Access to this resource is disabled.
@@ -246,7 +245,7 @@ class RevisionNotFoundError(HfHubHTTPError):
246
245
  >>> from huggingface_hub import hf_hub_download
247
246
  >>> hf_hub_download('bert-base-cased', 'config.json', revision='<non-existent-revision>')
248
247
  (...)
249
- huggingface_hub.utils._errors.RevisionNotFoundError: 404 Client Error. (Request ID: Mwhe_c3Kt650GcdKEFomX)
248
+ huggingface_hub.errors.RevisionNotFoundError: 404 Client Error. (Request ID: Mwhe_c3Kt650GcdKEFomX)
250
249
 
251
250
  Revision Not Found for url: https://huggingface.co/bert-base-cased/resolve/%3Cnon-existent-revision%3E/config.json.
252
251
  ```
@@ -254,7 +253,25 @@ class RevisionNotFoundError(HfHubHTTPError):
254
253
 
255
254
 
256
255
  # ENTRY ERRORS
257
- class EntryNotFoundError(HfHubHTTPError):
256
+ class EntryNotFoundError(Exception):
257
+ """
258
+ Raised when entry not found, either locally or remotely.
259
+
260
+ Example:
261
+
262
+ ```py
263
+ >>> from huggingface_hub import hf_hub_download
264
+ >>> hf_hub_download('bert-base-cased', '<non-existent-file>')
265
+ (...)
266
+ huggingface_hub.errors.RemoteEntryNotFoundError (...)
267
+ >>> hf_hub_download('bert-base-cased', '<non-existent-file>', local_files_only=True)
268
+ (...)
269
+ huggingface_hub.utils.errors.LocalEntryNotFoundError (...)
270
+ ```
271
+ """
272
+
273
+
274
+ class RemoteEntryNotFoundError(HfHubHTTPError, EntryNotFoundError):
258
275
  """
259
276
  Raised when trying to access a hf.co URL with a valid repository and revision
260
277
  but an invalid filename.
@@ -265,34 +282,30 @@ class EntryNotFoundError(HfHubHTTPError):
265
282
  >>> from huggingface_hub import hf_hub_download
266
283
  >>> hf_hub_download('bert-base-cased', '<non-existent-file>')
267
284
  (...)
268
- huggingface_hub.utils._errors.EntryNotFoundError: 404 Client Error. (Request ID: 53pNl6M0MxsnG5Sw8JA6x)
285
+ huggingface_hub.errors.EntryNotFoundError: 404 Client Error. (Request ID: 53pNl6M0MxsnG5Sw8JA6x)
269
286
 
270
287
  Entry Not Found for url: https://huggingface.co/bert-base-cased/resolve/main/%3Cnon-existent-file%3E.
271
288
  ```
272
289
  """
273
290
 
274
291
 
275
- class LocalEntryNotFoundError(EntryNotFoundError, FileNotFoundError, ValueError):
292
+ class LocalEntryNotFoundError(FileNotFoundError, EntryNotFoundError):
276
293
  """
277
294
  Raised when trying to access a file or snapshot that is not on the disk when network is
278
295
  disabled or unavailable (connection issue). The entry may exist on the Hub.
279
296
 
280
- Note: `ValueError` type is to ensure backward compatibility.
281
- Note: `LocalEntryNotFoundError` derives from `HTTPError` because of `EntryNotFoundError`
282
- even when it is not a network issue.
283
-
284
297
  Example:
285
298
 
286
299
  ```py
287
300
  >>> from huggingface_hub import hf_hub_download
288
301
  >>> hf_hub_download('bert-base-cased', '<non-cached-file>', local_files_only=True)
289
302
  (...)
290
- huggingface_hub.utils._errors.LocalEntryNotFoundError: Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable hf.co look-ups and downloads online, set 'local_files_only' to False.
303
+ huggingface_hub.errors.LocalEntryNotFoundError: Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable hf.co look-ups and downloads online, set 'local_files_only' to False.
291
304
  ```
292
305
  """
293
306
 
294
307
  def __init__(self, message: str):
295
- super().__init__(message, response=None)
308
+ super().__init__(message)
296
309
 
297
310
 
298
311
  # REQUEST ERROR
@@ -303,9 +316,9 @@ class BadRequestError(HfHubHTTPError, ValueError):
303
316
  Example:
304
317
 
305
318
  ```py
306
- >>> resp = requests.post("hf.co/api/check", ...)
319
+ >>> resp = httpx.post("hf.co/api/check", ...)
307
320
  >>> hf_raise_for_status(resp, endpoint_name="check")
308
- huggingface_hub.utils._errors.BadRequestError: Bad request for check endpoint: {details} (Request ID: XXX)
321
+ huggingface_hub.errors.BadRequestError: Bad request for check endpoint: {details} (Request ID: XXX)
309
322
  ```
310
323
  """
311
324
 
@@ -2,7 +2,7 @@ import json
2
2
  import os
3
3
  from pathlib import Path
4
4
  from pickle import DEFAULT_PROTOCOL, PicklingError
5
- from typing import Any, Dict, List, Optional, Union
5
+ from typing import Any, Optional, Union
6
6
 
7
7
  from packaging import version
8
8
 
@@ -16,7 +16,6 @@ from huggingface_hub.utils import (
16
16
  )
17
17
 
18
18
  from .utils import logging, validate_hf_hub_args
19
- from .utils._runtime import _PY_VERSION # noqa: F401 # for backward compatibility...
20
19
 
21
20
 
22
21
  logger = logging.get_logger(__name__)
@@ -241,7 +240,7 @@ def _create_model_pyproject(repo_dir: Path):
241
240
  def _save_pretrained_fastai(
242
241
  learner,
243
242
  save_directory: Union[str, Path],
244
- config: Optional[Dict[str, Any]] = None,
243
+ config: Optional[dict[str, Any]] = None,
245
244
  ):
246
245
  """
247
246
  Saves a fastai learner to `save_directory` in pickle format using the default pickle protocol for the version of python used.
@@ -350,9 +349,9 @@ def push_to_hub_fastai(
350
349
  config: Optional[dict] = None,
351
350
  branch: Optional[str] = None,
352
351
  create_pr: Optional[bool] = None,
353
- allow_patterns: Optional[Union[List[str], str]] = None,
354
- ignore_patterns: Optional[Union[List[str], str]] = None,
355
- delete_patterns: Optional[Union[List[str], str]] = None,
352
+ allow_patterns: Optional[Union[list[str], str]] = None,
353
+ ignore_patterns: Optional[Union[list[str], str]] = None,
354
+ delete_patterns: Optional[Union[list[str], str]] = None,
356
355
  api_endpoint: Optional[str] = None,
357
356
  ):
358
357
  """
@@ -385,11 +384,11 @@ def push_to_hub_fastai(
385
384
  Defaults to `False`.
386
385
  api_endpoint (`str`, *optional*):
387
386
  The API endpoint to use when pushing the model to the hub.
388
- allow_patterns (`List[str]` or `str`, *optional*):
387
+ allow_patterns (`list[str]` or `str`, *optional*):
389
388
  If provided, only files matching at least one pattern are pushed.
390
- ignore_patterns (`List[str]` or `str`, *optional*):
389
+ ignore_patterns (`list[str]` or `str`, *optional*):
391
390
  If provided, files matching any of the patterns are not pushed.
392
- delete_patterns (`List[str]` or `str`, *optional*):
391
+ delete_patterns (`list[str]` or `str`, *optional*):
393
392
  If provided, remote files matching any of the patterns will be deleted from the repo.
394
393
 
395
394
  Returns: