huggingface-hub 0.35.0rc0__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 (127) 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 +176 -20
  6. huggingface_hub/_local_folder.py +1 -1
  7. huggingface_hub/_login.py +13 -39
  8. huggingface_hub/_oauth.py +10 -14
  9. huggingface_hub/_snapshot_download.py +14 -28
  10. huggingface_hub/_space_api.py +4 -4
  11. huggingface_hub/_tensorboard_logger.py +13 -14
  12. huggingface_hub/_upload_large_folder.py +120 -13
  13. huggingface_hub/_webhooks_payload.py +3 -3
  14. huggingface_hub/_webhooks_server.py +2 -2
  15. huggingface_hub/cli/_cli_utils.py +2 -2
  16. huggingface_hub/cli/auth.py +8 -6
  17. huggingface_hub/cli/cache.py +18 -20
  18. huggingface_hub/cli/download.py +4 -4
  19. huggingface_hub/cli/hf.py +2 -5
  20. huggingface_hub/cli/jobs.py +599 -22
  21. huggingface_hub/cli/lfs.py +4 -4
  22. huggingface_hub/cli/repo.py +11 -7
  23. huggingface_hub/cli/repo_files.py +2 -2
  24. huggingface_hub/cli/upload.py +4 -4
  25. huggingface_hub/cli/upload_large_folder.py +3 -3
  26. huggingface_hub/commands/_cli_utils.py +2 -2
  27. huggingface_hub/commands/delete_cache.py +13 -13
  28. huggingface_hub/commands/download.py +4 -13
  29. huggingface_hub/commands/lfs.py +4 -4
  30. huggingface_hub/commands/repo_files.py +2 -2
  31. huggingface_hub/commands/scan_cache.py +1 -1
  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 -19
  39. huggingface_hub/errors.py +42 -29
  40. huggingface_hub/fastai_utils.py +8 -9
  41. huggingface_hub/file_download.py +162 -259
  42. huggingface_hub/hf_api.py +841 -616
  43. huggingface_hub/hf_file_system.py +98 -62
  44. huggingface_hub/hub_mixin.py +37 -57
  45. huggingface_hub/inference/_client.py +257 -325
  46. huggingface_hub/inference/_common.py +110 -124
  47. huggingface_hub/inference/_generated/_async_client.py +307 -432
  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 +18 -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/_cli_hacks.py +3 -3
  67. huggingface_hub/inference/_mcp/agent.py +3 -3
  68. huggingface_hub/inference/_mcp/cli.py +1 -1
  69. huggingface_hub/inference/_mcp/constants.py +2 -3
  70. huggingface_hub/inference/_mcp/mcp_client.py +58 -30
  71. huggingface_hub/inference/_mcp/types.py +10 -7
  72. huggingface_hub/inference/_mcp/utils.py +11 -7
  73. huggingface_hub/inference/_providers/__init__.py +4 -2
  74. huggingface_hub/inference/_providers/_common.py +49 -25
  75. huggingface_hub/inference/_providers/black_forest_labs.py +6 -6
  76. huggingface_hub/inference/_providers/cohere.py +3 -3
  77. huggingface_hub/inference/_providers/fal_ai.py +52 -21
  78. huggingface_hub/inference/_providers/featherless_ai.py +4 -4
  79. huggingface_hub/inference/_providers/fireworks_ai.py +3 -3
  80. huggingface_hub/inference/_providers/hf_inference.py +28 -20
  81. huggingface_hub/inference/_providers/hyperbolic.py +4 -4
  82. huggingface_hub/inference/_providers/nebius.py +10 -10
  83. huggingface_hub/inference/_providers/novita.py +5 -5
  84. huggingface_hub/inference/_providers/nscale.py +4 -4
  85. huggingface_hub/inference/_providers/replicate.py +15 -15
  86. huggingface_hub/inference/_providers/sambanova.py +6 -6
  87. huggingface_hub/inference/_providers/together.py +7 -7
  88. huggingface_hub/lfs.py +20 -31
  89. huggingface_hub/repocard.py +18 -18
  90. huggingface_hub/repocard_data.py +56 -56
  91. huggingface_hub/serialization/__init__.py +0 -1
  92. huggingface_hub/serialization/_base.py +9 -9
  93. huggingface_hub/serialization/_dduf.py +7 -7
  94. huggingface_hub/serialization/_torch.py +28 -28
  95. huggingface_hub/utils/__init__.py +10 -4
  96. huggingface_hub/utils/_auth.py +5 -5
  97. huggingface_hub/utils/_cache_manager.py +31 -31
  98. huggingface_hub/utils/_deprecation.py +1 -1
  99. huggingface_hub/utils/_dotenv.py +25 -21
  100. huggingface_hub/utils/_fixes.py +0 -10
  101. huggingface_hub/utils/_git_credential.py +4 -4
  102. huggingface_hub/utils/_headers.py +7 -29
  103. huggingface_hub/utils/_http.py +366 -208
  104. huggingface_hub/utils/_pagination.py +4 -4
  105. huggingface_hub/utils/_paths.py +5 -5
  106. huggingface_hub/utils/_runtime.py +16 -13
  107. huggingface_hub/utils/_safetensors.py +21 -21
  108. huggingface_hub/utils/_subprocess.py +9 -9
  109. huggingface_hub/utils/_telemetry.py +3 -3
  110. huggingface_hub/utils/_typing.py +25 -5
  111. huggingface_hub/utils/_validators.py +53 -72
  112. huggingface_hub/utils/_xet.py +16 -16
  113. huggingface_hub/utils/_xet_progress_reporting.py +32 -11
  114. huggingface_hub/utils/insecure_hashlib.py +3 -9
  115. huggingface_hub/utils/tqdm.py +3 -3
  116. {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-1.0.0rc0.dist-info}/METADATA +18 -29
  117. huggingface_hub-1.0.0rc0.dist-info/RECORD +161 -0
  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.0rc0.dist-info/RECORD +0 -166
  124. {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-1.0.0rc0.dist-info}/LICENSE +0 -0
  125. {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-1.0.0rc0.dist-info}/WHEEL +0 -0
  126. {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-1.0.0rc0.dist-info}/entry_points.txt +0 -0
  127. {huggingface_hub-0.35.0rc0.dist-info → huggingface_hub-1.0.0rc0.dist-info}/top_level.txt +0 -0
@@ -4,11 +4,8 @@ from functools import wraps
4
4
  from typing import (
5
5
  Any,
6
6
  Callable,
7
- Dict,
8
- List,
9
7
  Literal,
10
8
  Optional,
11
- Tuple,
12
9
  Type,
13
10
  TypeVar,
14
11
  Union,
@@ -102,7 +99,7 @@ def strict(
102
99
  )
103
100
 
104
101
  # List and store validators
105
- field_validators: Dict[str, List[Validator_T]] = {}
102
+ field_validators: dict[str, list[Validator_T]] = {}
106
103
  for f in fields(cls): # type: ignore [arg-type]
107
104
  validators = []
108
105
  validators.append(_create_type_validator(f))
@@ -238,14 +235,14 @@ def strict(
238
235
 
239
236
 
240
237
  def validated_field(
241
- validator: Union[List[Validator_T], Validator_T],
238
+ validator: Union[list[Validator_T], Validator_T],
242
239
  default: Union[Any, _MISSING_TYPE] = MISSING,
243
240
  default_factory: Union[Callable[[], Any], _MISSING_TYPE] = MISSING,
244
241
  init: bool = True,
245
242
  repr: bool = True,
246
243
  hash: Optional[bool] = None,
247
244
  compare: bool = True,
248
- metadata: Optional[Dict] = None,
245
+ metadata: Optional[dict] = None,
249
246
  **kwargs: Any,
250
247
  ) -> Any:
251
248
  """
@@ -254,7 +251,7 @@ def validated_field(
254
251
  Useful to apply several checks to a field. If only applying one rule, check out the [`as_validated_field`] decorator.
255
252
 
256
253
  Args:
257
- validator (`Callable` or `List[Callable]`):
254
+ validator (`Callable` or `list[Callable]`):
258
255
  A method that takes a value as input and raises ValueError/TypeError if the value is invalid.
259
256
  Can be a list of validators to apply multiple checks.
260
257
  **kwargs:
@@ -296,7 +293,7 @@ def as_validated_field(validator: Validator_T):
296
293
  repr: bool = True,
297
294
  hash: Optional[bool] = None,
298
295
  compare: bool = True,
299
- metadata: Optional[Dict] = None,
296
+ metadata: Optional[dict] = None,
300
297
  **kwargs: Any,
301
298
  ):
302
299
  return validated_field(
@@ -329,7 +326,7 @@ def type_validator(name: str, value: Any, expected_type: Any) -> None:
329
326
  raise TypeError(f"Unsupported type for field '{name}': {expected_type}")
330
327
 
331
328
 
332
- def _validate_union(name: str, value: Any, args: Tuple[Any, ...]) -> None:
329
+ def _validate_union(name: str, value: Any, args: tuple[Any, ...]) -> None:
333
330
  """Validate that value matches one of the types in a Union."""
334
331
  errors = []
335
332
  for t in args:
@@ -344,14 +341,14 @@ def _validate_union(name: str, value: Any, args: Tuple[Any, ...]) -> None:
344
341
  )
345
342
 
346
343
 
347
- def _validate_literal(name: str, value: Any, args: Tuple[Any, ...]) -> None:
344
+ def _validate_literal(name: str, value: Any, args: tuple[Any, ...]) -> None:
348
345
  """Validate Literal type."""
349
346
  if value not in args:
350
347
  raise TypeError(f"Field '{name}' expected one of {args}, got {value}")
351
348
 
352
349
 
353
- def _validate_list(name: str, value: Any, args: Tuple[Any, ...]) -> None:
354
- """Validate List[T] type."""
350
+ def _validate_list(name: str, value: Any, args: tuple[Any, ...]) -> None:
351
+ """Validate list[T] type."""
355
352
  if not isinstance(value, list):
356
353
  raise TypeError(f"Field '{name}' expected a list, got {type(value).__name__}")
357
354
 
@@ -364,8 +361,8 @@ def _validate_list(name: str, value: Any, args: Tuple[Any, ...]) -> None:
364
361
  raise TypeError(f"Invalid item at index {i} in list '{name}'") from e
365
362
 
366
363
 
367
- def _validate_dict(name: str, value: Any, args: Tuple[Any, ...]) -> None:
368
- """Validate Dict[K, V] type."""
364
+ def _validate_dict(name: str, value: Any, args: tuple[Any, ...]) -> None:
365
+ """Validate dict[K, V] type."""
369
366
  if not isinstance(value, dict):
370
367
  raise TypeError(f"Field '{name}' expected a dict, got {type(value).__name__}")
371
368
 
@@ -379,19 +376,19 @@ def _validate_dict(name: str, value: Any, args: Tuple[Any, ...]) -> None:
379
376
  raise TypeError(f"Invalid key or value in dict '{name}'") from e
380
377
 
381
378
 
382
- def _validate_tuple(name: str, value: Any, args: Tuple[Any, ...]) -> None:
379
+ def _validate_tuple(name: str, value: Any, args: tuple[Any, ...]) -> None:
383
380
  """Validate Tuple type."""
384
381
  if not isinstance(value, tuple):
385
382
  raise TypeError(f"Field '{name}' expected a tuple, got {type(value).__name__}")
386
383
 
387
- # Handle variable-length tuples: Tuple[T, ...]
384
+ # Handle variable-length tuples: tuple[T, ...]
388
385
  if len(args) == 2 and args[1] is Ellipsis:
389
386
  for i, item in enumerate(value):
390
387
  try:
391
388
  type_validator(f"{name}[{i}]", item, args[0])
392
389
  except TypeError as e:
393
390
  raise TypeError(f"Invalid item at index {i} in tuple '{name}'") from e
394
- # Handle fixed-length tuples: Tuple[T1, T2, ...]
391
+ # Handle fixed-length tuples: tuple[T1, T2, ...]
395
392
  elif len(args) != len(value):
396
393
  raise TypeError(f"Field '{name}' expected a tuple of length {len(args)}, got {len(value)}")
397
394
  else:
@@ -402,8 +399,8 @@ def _validate_tuple(name: str, value: Any, args: Tuple[Any, ...]) -> None:
402
399
  raise TypeError(f"Invalid item at index {i} in tuple '{name}'") from e
403
400
 
404
401
 
405
- def _validate_set(name: str, value: Any, args: Tuple[Any, ...]) -> None:
406
- """Validate Set[T] type."""
402
+ def _validate_set(name: str, value: Any, args: tuple[Any, ...]) -> None:
403
+ """Validate set[T] type."""
407
404
  if not isinstance(value, set):
408
405
  raise TypeError(f"Field '{name}' expected a set, got {type(value).__name__}")
409
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
@@ -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: