Skip to content

Commit

Permalink
refactor(URLRequired): Deprecate URLRequired exception with warning
Browse files Browse the repository at this point in the history
`requests.URLRequired` has been dead code since ab27027 (2012) and is
never raised. This commit adds a `DeprecationWarning` to notify users
that it will be removed in a future version. Invalid URLs instead
raise `MissingSchema`, `InvalidSchema`, or `InvalidURL`.

Signed-off-by: jakobheine <[email protected]>
  • Loading branch information
jakobheine committed Feb 1, 2025
1 parent fe0583b commit ce01dd4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/requests/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module contains the set of Requests' exceptions.
"""
import warnings
from urllib3.exceptions import HTTPError as BaseHTTPError

from .compat import JSONDecodeError as CompatJSONDecodeError
Expand Down Expand Up @@ -91,6 +92,14 @@ class ReadTimeout(Timeout):
class URLRequired(RequestException):
"""A valid URL is required to make a request."""

def __init__(self, *args, **kwargs):
warnings.warn(
"URLRequired exception is deprecated and will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class TooManyRedirects(RequestException):
"""Too many redirects."""
Expand Down

0 comments on commit ce01dd4

Please sign in to comment.