Skip to content

Commit fd19bd9

Browse files
committed
Add deprecation notices to old URIReference methods
1 parent 513f70b commit fd19bd9

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

docs/source/api-ref/uri.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,19 @@
1717
.. automethod:: rfc3986.uri.URIReference.is_absolute
1818

1919
.. automethod:: rfc3986.uri.URIReference.authority_info
20+
21+
22+
Deprecated Methods
23+
==================
24+
25+
.. automethod:: rfc3986.uri.URIReference.is_valid
26+
27+
.. automethod:: rfc3986.uri.URIReference.authority_is_valid
28+
29+
.. automethod:: rfc3986.uri.URIReference.scheme_is_valid
30+
31+
.. automethod:: rfc3986.uri.URIReference.path_is_valid
32+
33+
.. automethod:: rfc3986.uri.URIReference.query_is_valid
34+
35+
.. automethod:: rfc3986.uri.URIReference.fragment_is_valid

src/rfc3986/uri.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
from collections import namedtuple
18+
import warnings
1819

1920
from . import compat
2021
from . import exceptions as exc
@@ -210,6 +211,10 @@ def is_absolute(self):
210211
def is_valid(self, **kwargs):
211212
"""Determine if the URI is valid.
212213
214+
.. deprecated:: 1.1.0
215+
216+
Use the :class:`~rfc3986.validators.Validator` object instead.
217+
213218
:param bool require_scheme: Set to ``True`` if you wish to require the
214219
presence of the scheme component.
215220
:param bool require_authority: Set to ``True`` if you wish to require
@@ -223,6 +228,9 @@ def is_valid(self, **kwargs):
223228
:returns: ``True`` if the URI is valid. ``False`` otherwise.
224229
:rtype: bool
225230
"""
231+
warnings.warn("Please use rfc3986.validators.Validator instead. "
232+
"This method will be eventually removed.",
233+
DeprecationWarning)
226234
validators = [
227235
(self.scheme_is_valid, kwargs.get('require_scheme', False)),
228236
(self.authority_is_valid, kwargs.get('require_authority', False)),
@@ -235,13 +243,20 @@ def is_valid(self, **kwargs):
235243
def authority_is_valid(self, require=False):
236244
"""Determine if the authority component is valid.
237245
246+
.. deprecated:: 1.1.0
247+
248+
Use the :class:`~rfc3986.validators.Validator` object instead.
249+
238250
:param bool require:
239251
Set to ``True`` to require the presence of this component.
240252
:returns:
241253
``True`` if the authority is valid. ``False`` otherwise.
242254
:rtype:
243255
bool
244256
"""
257+
warnings.warn("Please use rfc3986.validators.Validator instead. "
258+
"This method will be eventually removed.",
259+
DeprecationWarning)
245260
try:
246261
self.authority_info()
247262
except exc.InvalidAuthority:
@@ -256,41 +271,69 @@ def authority_is_valid(self, require=False):
256271
def scheme_is_valid(self, require=False):
257272
"""Determine if the scheme component is valid.
258273
274+
.. deprecated:: 1.1.0
275+
276+
Use the :class:`~rfc3986.validators.Validator` object instead.
277+
259278
:param str require: Set to ``True`` to require the presence of this
260279
component.
261280
:returns: ``True`` if the scheme is valid. ``False`` otherwise.
262281
:rtype: bool
263282
"""
283+
warnings.warn("Please use rfc3986.validators.Validator instead. "
284+
"This method will be eventually removed.",
285+
DeprecationWarning)
264286
return validators.scheme_is_valid(self.scheme, require)
265287

266288
def path_is_valid(self, require=False):
267289
"""Determine if the path component is valid.
268290
291+
.. deprecated:: 1.1.0
292+
293+
Use the :class:`~rfc3986.validators.Validator` object instead.
294+
269295
:param str require: Set to ``True`` to require the presence of this
270296
component.
271297
:returns: ``True`` if the path is valid. ``False`` otherwise.
272298
:rtype: bool
273299
"""
300+
warnings.warn("Please use rfc3986.validators.Validator instead. "
301+
"This method will be eventually removed.",
302+
DeprecationWarning)
274303
return validators.path_is_valid(self.path, require)
275304

276305
def query_is_valid(self, require=False):
277306
"""Determine if the query component is valid.
278307
308+
.. deprecated:: 1.1.0
309+
310+
Use the :class:`~rfc3986.validators.Validator` object instead.
311+
279312
:param str require: Set to ``True`` to require the presence of this
280313
component.
281314
:returns: ``True`` if the query is valid. ``False`` otherwise.
282315
:rtype: bool
283316
"""
317+
warnings.warn("Please use rfc3986.validators.Validator instead. "
318+
"This method will be eventually removed.",
319+
DeprecationWarning)
284320
return validators.query_is_valid(self.query, require)
285321

286322
def fragment_is_valid(self, require=False):
287323
"""Determine if the fragment component is valid.
288324
325+
.. deprecated:: 1.1.0
326+
327+
Use the Validator object instead.
328+
289329
:param str require: Set to ``True`` to require the presence of this
290330
component.
291331
:returns: ``True`` if the fragment is valid. ``False`` otherwise.
292332
:rtype: bool
293333
"""
334+
warnings.warn("Please use rfc3986.validators.Validator instead. "
335+
"This method will be eventually removed.",
336+
DeprecationWarning)
294337
return validators.fragment_is_valid(self.fragment, require)
295338

296339
def normalize(self):

0 commit comments

Comments
 (0)