diff --git a/src/huggingface_hub/utils/_errors.py b/src/huggingface_hub/utils/_errors.py index be30c2f1ea..7a7d99fbd9 100644 --- a/src/huggingface_hub/utils/_errors.py +++ b/src/huggingface_hub/utils/_errors.py @@ -2,7 +2,6 @@ from requests import HTTPError, Response -from ._deprecation import _deprecate_method from ._fixes import JSONDecodeError @@ -302,28 +301,6 @@ def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) raise HfHubHTTPError(str(e), response=response) from e -@_deprecate_method(version="0.13", message="Use `hf_raise_for_status` instead.") -def _raise_for_status(response): - """Keep alias for now.""" - hf_raise_for_status(response) - - -@_deprecate_method(version="0.13", message="Use `hf_raise_for_status` instead.") -def _raise_with_request_id(response): - """Keep alias for now.""" - hf_raise_for_status(response) - - -@_deprecate_method(version="0.13", message="Use `hf_raise_for_status` instead.") -def _raise_convert_bad_request(response: Response, endpoint_name: str): - """ - Calls hf_raise_for_status on resp and converts HTTP 400 errors into ValueError. - - Keep alias for now. - """ - hf_raise_for_status(response, endpoint_name=endpoint_name) - - def _format_error_message(message: str, request_id: Optional[str], server_message: Optional[str]) -> str: """ Format the `HfHubHTTPError` error message based on initial message and information diff --git a/tests/test_utils_errors.py b/tests/test_utils_errors.py index a761da1d76..af469f9c29 100644 --- a/tests/test_utils_errors.py +++ b/tests/test_utils_errors.py @@ -1,5 +1,4 @@ import unittest -from unittest.mock import Mock, patch from requests.models import Response @@ -9,14 +8,9 @@ HfHubHTTPError, RepositoryNotFoundError, RevisionNotFoundError, - _raise_convert_bad_request, - _raise_for_status, - _raise_with_request_id, hf_raise_for_status, ) -from .testing_utils import expect_deprecation - class TestErrorUtils(unittest.TestCase): def test_hf_raise_for_status_repo_not_found(self) -> None: @@ -89,31 +83,6 @@ def test_hf_raise_for_status_fallback(self) -> None: self.assertEqual(context.exception.response.status_code, 404) self.assertEqual(context.exception.response.url, "test_URL") - @expect_deprecation("_raise_for_status") - @patch("huggingface_hub.utils._errors.hf_raise_for_status") - def test_raise_for_status(self, mock_hf_raise_for_status: Mock) -> None: - """Test `_raise_for_status` alias.""" - response_mock = Mock() - _raise_for_status(response_mock) - mock_hf_raise_for_status.assert_called_once_with(response_mock) - - @expect_deprecation("_raise_with_request_id") - @patch("huggingface_hub.utils._errors.hf_raise_for_status") - def test_raise_with_request_id(self, mock_hf_raise_for_status: Mock) -> None: - """Test `_raise_with_request_id` alias.""" - response_mock = Mock() - _raise_with_request_id(response_mock) - mock_hf_raise_for_status.assert_called_once_with(response_mock) - - @expect_deprecation("_raise_convert_bad_request") - @patch("huggingface_hub.utils._errors.hf_raise_for_status") - def test_raise_convert_bad_request(self, mock_hf_raise_for_status: Mock) -> None: - """Test `_raise_convert_bad_request` alias.""" - response_mock = Mock() - endpoint_name_mock = Mock() - _raise_convert_bad_request(response_mock, endpoint_name_mock) - mock_hf_raise_for_status.assert_called_once_with(response_mock, endpoint_name=endpoint_name_mock) - class TestHfHubHTTPError(unittest.TestCase): response: Response