Skip to content

Commit b2b9937

Browse files
committed
Don't use deprecated methods in resolve_with()
resolve_with(), which is not deprecated, was using the deprecated is_valid() method. Replaced with a lazily instantiated validator object.
1 parent 3875725 commit b2b9937

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/rfc3986/_mixin.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ def authority_info(self):
5656
def _match_subauthority(self):
5757
return misc.SUBAUTHORITY_MATCHER.match(self.authority)
5858

59+
def _get_base_uri_validator(self):
60+
try:
61+
return self._base_uri_validator
62+
except AttributeError:
63+
self._base_uri_validator = (
64+
validators.Validator().require_presence_of("scheme")
65+
)
66+
return self._base_uri_validator
67+
5968
@property
6069
def host(self):
6170
"""If present, a string representing the host."""
@@ -262,7 +271,9 @@ def resolve_with(self, base_uri, strict=False):
262271
if not isinstance(base_uri, URIMixin):
263272
base_uri = type(self).from_string(base_uri)
264273

265-
if not base_uri.is_valid(require_scheme=True):
274+
try:
275+
self._get_base_uri_validator().validate(base_uri)
276+
except exc.ValidationError:
266277
raise exc.ResolutionError(base_uri)
267278

268279
# This is optional per

0 commit comments

Comments
 (0)