Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated code (0.13) #1359

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/huggingface_hub/utils/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from requests import HTTPError, Response

from ._deprecation import _deprecate_method
from ._fixes import JSONDecodeError


Expand Down Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions tests/test_utils_errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
from unittest.mock import Mock, patch

from requests.models import Response

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down