Skip to content

Commit a3a6d9e

Browse files
committed
style
1 parent 65753c4 commit a3a6d9e

File tree

7 files changed

+26
-33
lines changed

7 files changed

+26
-33
lines changed

src/huggingface_hub/fastai_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
from packaging import version
88

9-
from huggingface_hub import snapshot_download
10-
from huggingface_hub import constants
9+
from huggingface_hub import constants, snapshot_download
1110
from huggingface_hub.hf_api import HfApi
1211
from huggingface_hub.utils import (
1312
SoftTemporaryDirectory,

src/huggingface_hub/file_download.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,19 @@
1818

1919
import requests
2020

21-
from . import (__version__ , # noqa: F401 # for backward compatibility
22-
constants,
21+
from . import (
22+
__version__, # noqa: F401 # for backward compatibility
23+
constants,
2324
)
2425
from ._local_folder import (
2526
get_local_download_paths,
2627
read_download_metadata,
2728
write_download_metadata,
2829
)
2930
from .constants import (
30-
DEFAULT_ETAG_TIMEOUT,
31-
DEFAULT_REQUEST_TIMEOUT,
32-
DEFAULT_REVISION,
33-
DOWNLOAD_CHUNK_SIZE,
34-
ENDPOINT,
35-
HF_HUB_CACHE,
36-
HF_HUB_DISABLE_SYMLINKS_WARNING,
37-
HF_HUB_DOWNLOAD_TIMEOUT,
38-
HF_HUB_ENABLE_HF_TRANSFER,
39-
HF_HUB_ETAG_TIMEOUT,
40-
HF_TRANSFER_CONCURRENCY,
4131
HUGGINGFACE_CO_URL_TEMPLATE, # noqa: F401 # for backward compatibility
42-
HUGGINGFACE_HEADER_X_LINKED_ETAG,
43-
HUGGINGFACE_HEADER_X_LINKED_SIZE,
44-
HUGGINGFACE_HEADER_X_REPO_COMMIT,
4532
HUGGINGFACE_HUB_CACHE, # noqa: F401 # for backward compatibility
46-
REPO_ID_SEPARATOR,
47-
REPO_TYPES,
48-
REPO_TYPES_URL_PREFIXES,
49-
)
33+
)
5034
from .errors import (
5135
EntryNotFoundError,
5236
FileMetadataError,
@@ -1695,7 +1679,9 @@ def get_hf_file_metadata(
16951679
# Do not use directly `url`, as `_request_wrapper` might have followed relative
16961680
# redirects.
16971681
location=r.headers.get("Location") or r.request.url, # type: ignore
1698-
size=_int_or_none(r.headers.get(constants.HUGGINGFACE_HEADER_X_LINKED_SIZE) or r.headers.get("Content-Length")),
1682+
size=_int_or_none(
1683+
r.headers.get(constants.HUGGINGFACE_HEADER_X_LINKED_SIZE) or r.headers.get("Content-Length")
1684+
),
16991685
)
17001686

17011687

src/huggingface_hub/hf_file_system.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from fsspec.utils import isfilelike
1616
from requests import Response
1717

18-
from ._commit_api import CommitOperationCopy, CommitOperationDelete
1918
from . import constants
19+
from ._commit_api import CommitOperationCopy, CommitOperationDelete
2020
from .errors import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError
2121
from .file_download import hf_hub_url, http_get
2222
from .hf_api import HfApi, LastCommitInfo, RepoFile
@@ -118,7 +118,9 @@ def _repo_and_revision_exist(
118118
) -> Tuple[bool, Optional[Exception]]:
119119
if (repo_type, repo_id, revision) not in self._repo_and_revision_exists_cache:
120120
try:
121-
self._api.repo_info(repo_id, revision=revision, repo_type=repo_type, timeout=constants.HF_HUB_ETAG_TIMEOUT)
121+
self._api.repo_info(
122+
repo_id, revision=revision, repo_type=repo_type, timeout=constants.HF_HUB_ETAG_TIMEOUT
123+
)
122124
except (RepositoryNotFoundError, HFValidationError) as e:
123125
self._repo_and_revision_exists_cache[(repo_type, repo_id, revision)] = False, e
124126
self._repo_and_revision_exists_cache[(repo_type, repo_id, None)] = False, e

tests/test_file_download.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,9 @@ def test_try_to_load_from_cache_specific_pr_revision_exists(self):
592592
self.assertIsNone(try_to_load_from_cache(DUMMY_MODEL_ID, filename="conf.json", revision="refs/pr/1"))
593593

594594
# If revision does not exist, returns None
595-
self.assertIsNone(try_to_load_from_cache(DUMMY_MODEL_ID, filename=constants.CONFIG_NAME, revision="does-not-exist"))
595+
self.assertIsNone(
596+
try_to_load_from_cache(DUMMY_MODEL_ID, filename=constants.CONFIG_NAME, revision="does-not-exist")
597+
)
596598

597599
def test_try_to_load_from_cache_no_exist(self):
598600
# Make sure the file is cached
@@ -1255,7 +1257,9 @@ def test_resolve_endpoint_on_lfs_file(self):
12551257
@staticmethod
12561258
def _get_etag_and_normalize(response: Response) -> str:
12571259
response.raise_for_status()
1258-
return _normalize_etag(response.headers.get(constants.HUGGINGFACE_HEADER_X_LINKED_ETAG) or response.headers.get("ETag"))
1260+
return _normalize_etag(
1261+
response.headers.get(constants.HUGGINGFACE_HEADER_X_LINKED_ETAG) or response.headers.get("ETag")
1262+
)
12591263

12601264

12611265
@with_production_testing

tests/test_hub_mixin_pytorch.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
import pytest
1111

12-
from huggingface_hub import HfApi, ModelCard, hf_hub_download
13-
from huggingface_hub import constants
12+
from huggingface_hub import HfApi, ModelCard, constants, hf_hub_download
1413
from huggingface_hub.errors import EntryNotFoundError, HfHubHTTPError
1514
from huggingface_hub.hub_mixin import ModelHubMixin, PyTorchModelHubMixin
1615
from huggingface_hub.serialization._torch import storage_ptr

tests/test_lfs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from huggingface_hub.lfs import SliceFileObj, UploadInfo
77
from huggingface_hub.utils import SoftTemporaryDirectory
8-
from huggingface_hub import file_download
98

109

1110
class TestUploadInfo(unittest.TestCase):

tests/test_repocard.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
RepoCard,
3030
SpaceCard,
3131
SpaceCardData,
32+
constants,
3233
get_hf_file_metadata,
3334
hf_hub_url,
3435
metadata_eval_result,
3536
metadata_load,
3637
metadata_save,
3738
metadata_update,
3839
)
39-
from huggingface_hub import constants
4040
from huggingface_hub.errors import EntryNotFoundError
4141
from huggingface_hub.file_download import hf_hub_download
4242
from huggingface_hub.hf_api import HfApi
@@ -278,7 +278,9 @@ def setUp(self) -> None:
278278

279279
self.repo_id = self.api.create_repo(repo_name()).repo_id
280280
self.api.upload_file(
281-
path_or_fileobj=DUMMY_MODELCARD_EVAL_RESULT.encode(), repo_id=self.repo_id, path_in_repo=constants.REPOCARD_NAME
281+
path_or_fileobj=DUMMY_MODELCARD_EVAL_RESULT.encode(),
282+
repo_id=self.repo_id,
283+
path_in_repo=constants.REPOCARD_NAME,
282284
)
283285
self.existing_metadata = yaml.safe_load(DUMMY_MODELCARD_EVAL_RESULT.strip().strip("-"))
284286

@@ -413,7 +415,9 @@ def test_update_metadata_on_empty_text_content(self) -> None:
413415
"""
414416
# Create modelcard with metadata but empty text content
415417
self.api.upload_file(
416-
path_or_fileobj=DUMMY_MODELCARD_NO_TEXT_CONTENT.encode(), path_in_repo=constants.REPOCARD_NAME, repo_id=self.repo_id
418+
path_or_fileobj=DUMMY_MODELCARD_NO_TEXT_CONTENT.encode(),
419+
path_in_repo=constants.REPOCARD_NAME,
420+
repo_id=self.repo_id,
417421
)
418422
metadata_update(self.repo_id, {"tag": "test"}, token=self.token)
419423

0 commit comments

Comments
 (0)