Skip to content

Commit b679858

Browse files
authored
[v1.0] Remove imports kept only for backward compatibility (#3350)
* Remove imports kept only for backward compatibility * fix tests
1 parent ccca22e commit b679858

File tree

5 files changed

+6
-49
lines changed

5 files changed

+6
-49
lines changed

src/huggingface_hub/fastai_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
)
1717

1818
from .utils import logging, validate_hf_hub_args
19-
from .utils._runtime import _PY_VERSION # noqa: F401 # for backward compatibility...
2019

2120

2221
logger = logging.get_logger(__name__)

src/huggingface_hub/file_download.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@
1414

1515
import httpx
1616

17-
from . import (
18-
__version__, # noqa: F401 # for backward compatibility
19-
constants,
20-
)
17+
from . import constants
2118
from ._local_folder import get_local_download_paths, read_download_metadata, write_download_metadata
22-
from .constants import (
23-
HUGGINGFACE_CO_URL_TEMPLATE, # noqa: F401 # for backward compatibility
24-
HUGGINGFACE_HUB_CACHE, # noqa: F401 # for backward compatibility
25-
)
2619
from .errors import (
2720
FileMetadataError,
2821
GatedRepoError,
@@ -38,29 +31,15 @@
3831
WeakFileLock,
3932
XetFileData,
4033
build_hf_headers,
41-
get_fastai_version, # noqa: F401 # for backward compatibility
42-
get_fastcore_version, # noqa: F401 # for backward compatibility
43-
get_graphviz_version, # noqa: F401 # for backward compatibility
44-
get_jinja_version, # noqa: F401 # for backward compatibility
45-
get_pydot_version, # noqa: F401 # for backward compatibility
46-
get_tf_version, # noqa: F401 # for backward compatibility
47-
get_torch_version, # noqa: F401 # for backward compatibility
4834
hf_raise_for_status,
49-
is_fastai_available, # noqa: F401 # for backward compatibility
50-
is_fastcore_available, # noqa: F401 # for backward compatibility
51-
is_graphviz_available, # noqa: F401 # for backward compatibility
52-
is_jinja_available, # noqa: F401 # for backward compatibility
53-
is_pydot_available, # noqa: F401 # for backward compatibility
54-
is_tf_available, # noqa: F401 # for backward compatibility
55-
is_torch_available, # noqa: F401 # for backward compatibility
5635
logging,
5736
parse_xet_file_data_from_response,
5837
refresh_xet_connection_info,
5938
tqdm,
6039
validate_hf_hub_args,
6140
)
6241
from .utils._http import _adjust_range_header, http_backoff, http_stream_backoff
63-
from .utils._runtime import _PY_VERSION, is_xet_available # noqa: F401 # for backward compatibility
42+
from .utils._runtime import is_xet_available
6443
from .utils._typing import HTTP_METHOD_T
6544
from .utils.sha import sha_fileobj
6645
from .utils.tqdm import _get_progress_bar_context
@@ -250,7 +229,7 @@ def hf_hub_url(
250229

251230
if revision is None:
252231
revision = constants.DEFAULT_REVISION
253-
url = HUGGINGFACE_CO_URL_TEMPLATE.format(
232+
url = constants.HUGGINGFACE_CO_URL_TEMPLATE.format(
254233
repo_id=repo_id, revision=quote(revision, safe=""), filename=quote(filename)
255234
)
256235
# Update endpoint if provided

src/huggingface_hub/hf_api.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,6 @@
7373
DiscussionWithDetails,
7474
deserialize_event,
7575
)
76-
from .constants import (
77-
DEFAULT_ETAG_TIMEOUT, # noqa: F401 # kept for backward compatibility
78-
DEFAULT_REQUEST_TIMEOUT, # noqa: F401 # kept for backward compatibility
79-
DEFAULT_REVISION, # noqa: F401 # kept for backward compatibility
80-
DISCUSSION_STATUS, # noqa: F401 # kept for backward compatibility
81-
DISCUSSION_TYPES, # noqa: F401 # kept for backward compatibility
82-
ENDPOINT, # noqa: F401 # kept for backward compatibility
83-
INFERENCE_ENDPOINTS_ENDPOINT, # noqa: F401 # kept for backward compatibility
84-
REGEX_COMMIT_OID, # noqa: F401 # kept for backward compatibility
85-
REPO_TYPE_MODEL, # noqa: F401 # kept for backward compatibility
86-
REPO_TYPES, # noqa: F401 # kept for backward compatibility
87-
REPO_TYPES_MAPPING, # noqa: F401 # kept for backward compatibility
88-
REPO_TYPES_URL_PREFIXES, # noqa: F401 # kept for backward compatibility
89-
SAFETENSORS_INDEX_FILE, # noqa: F401 # kept for backward compatibility
90-
SAFETENSORS_MAX_HEADER_LENGTH, # noqa: F401 # kept for backward compatibility
91-
SAFETENSORS_SINGLE_FILE, # noqa: F401 # kept for backward compatibility
92-
SPACES_SDK_TYPES, # noqa: F401 # kept for backward compatibility
93-
WEBHOOK_DOMAIN_T, # noqa: F401 # kept for backward compatibility
94-
DiscussionStatusFilter, # noqa: F401 # kept for backward compatibility
95-
DiscussionTypeFilter, # noqa: F401 # kept for backward compatibility
96-
)
9776
from .errors import (
9877
BadRequestError,
9978
GatedRepoError,

tests/test_file_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ def test_hf_hub_url_with_empty_subfolder(self):
355355
)
356356
)
357357

358-
@patch("huggingface_hub.file_download.constants.ENDPOINT", "https://huggingface.co")
358+
@patch("huggingface_hub.constants.ENDPOINT", "https://huggingface.co")
359359
@patch(
360-
"huggingface_hub.file_download.HUGGINGFACE_CO_URL_TEMPLATE",
360+
"huggingface_hub.constants.HUGGINGFACE_CO_URL_TEMPLATE",
361361
"https://huggingface.co/{repo_id}/resolve/{revision}/{filename}",
362362
)
363363
def test_hf_hub_url_with_endpoint(self):

tests/testing_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def rmtree_with_retry(path: Union[str, Path]) -> None:
243243

244244

245245
def with_production_testing(func):
246-
file_download = patch("huggingface_hub.file_download.HUGGINGFACE_CO_URL_TEMPLATE", ENDPOINT_PRODUCTION_URL_SCHEME)
246+
file_download = patch("huggingface_hub.constants.HUGGINGFACE_CO_URL_TEMPLATE", ENDPOINT_PRODUCTION_URL_SCHEME)
247247
hf_api = patch("huggingface_hub.constants.ENDPOINT", ENDPOINT_PRODUCTION)
248248
return hf_api(file_download(func))
249249

0 commit comments

Comments
 (0)