@@ -248,23 +248,27 @@ def is_idn_host_name(instance):
248
248
try :
249
249
import rfc3987
250
250
except ImportError :
251
- from jsonschema ._format_validators import validate_rfc3986
252
251
253
- @_checks_drafts (name = "uri" ,)
254
- def is_uri (instance ):
255
- if not isinstance (instance , str_types ):
256
- return True
257
- return validate_rfc3986 (instance , rule = "URI" )
258
-
259
- @_checks_drafts (
260
- draft6 = "uri-reference" ,
261
- draft7 = "uri-reference" ,
262
- raises = ValueError ,
263
- )
264
- def is_uri_reference (instance ):
265
- if not isinstance (instance , str_types ):
266
- return True
267
- return validate_rfc3986 (instance , rule = "URI_reference" )
252
+ try :
253
+ from rfc3986_validator import validate_rfc3986
254
+ except ImportError :
255
+ pass
256
+ else :
257
+ @_checks_drafts (name = "uri" ,)
258
+ def is_uri (instance ):
259
+ if not isinstance (instance , str_types ):
260
+ return True
261
+ return validate_rfc3986 (instance , rule = "URI" )
262
+
263
+ @_checks_drafts (
264
+ draft6 = "uri-reference" ,
265
+ draft7 = "uri-reference" ,
266
+ raises = ValueError ,
267
+ )
268
+ def is_uri_reference (instance ):
269
+ if not isinstance (instance , str_types ):
270
+ return True
271
+ return validate_rfc3986 (instance , rule = "URI_reference" )
268
272
269
273
else :
270
274
@_checks_drafts (draft7 = "iri" , raises = ValueError )
@@ -299,21 +303,23 @@ def is_uri_reference(instance):
299
303
try :
300
304
from strict_rfc3339 import validate_rfc3339
301
305
except ImportError :
302
- from jsonschema ._format_validators import validate_rfc3339
303
-
304
-
305
- @_checks_drafts (name = "date-time" )
306
- def is_datetime (instance ):
307
- if not isinstance (instance , str_types ):
308
- return True
309
- return validate_rfc3339 (instance )
310
-
306
+ try :
307
+ from rfc3339_validator import validate_rfc3339
308
+ except ImportError :
309
+ validate_rfc3339 = None
310
+
311
+ if validate_rfc3339 :
312
+ @_checks_drafts (name = "date-time" )
313
+ def is_datetime (instance ):
314
+ if not isinstance (instance , str_types ):
315
+ return True
316
+ return validate_rfc3339 (instance )
311
317
312
- @_checks_drafts (draft7 = "time" )
313
- def is_time (instance ):
314
- if not isinstance (instance , str_types ):
315
- return True
316
- return is_datetime ("1970-01-01T" + instance )
318
+ @_checks_drafts (draft7 = "time" )
319
+ def is_time (instance ):
320
+ if not isinstance (instance , str_types ):
321
+ return True
322
+ return is_datetime ("1970-01-01T" + instance )
317
323
318
324
319
325
@_checks_drafts (name = "regex" , raises = re .error )
0 commit comments