summaryrefslogtreecommitdiff
path: root/jsonschema/_format.py
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2020-08-12 16:23:23 -0400
committerJulian Berman <Julian@GrayVines.com>2020-08-12 17:22:02 -0400
commit95f38a61ab17610c564efa3d29a4354d46c56e13 (patch)
tree09da403bc7d5b1cbd3ec0cf4160bc682c688bdbb /jsonschema/_format.py
parenta646912c896e59ed0b7edc4a08132caa27127e1d (diff)
downloadjsonschema-95f38a61ab17610c564efa3d29a4354d46c56e13.tar.gz
Unbreak non-format-setuptools-extra-installed jsonschema.
Revert the changes to the docs requirements. fqdn is *not* a doc requirement, it's part of the package's requirements, but only when format validation is installed. The docs builds were failing because they do not install the format extra. This was actually a (known bad) CI gap, that we didn't run the tests against all the configurations (i.e. against jsonschema installed with no setuptools extras, say). Fixed in the previous commit, so now we can run this.
Diffstat (limited to 'jsonschema/_format.py')
-rw-r--r--jsonschema/_format.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/jsonschema/_format.py b/jsonschema/_format.py
index 36bacab..65e453e 100644
--- a/jsonschema/_format.py
+++ b/jsonschema/_format.py
@@ -3,8 +3,6 @@ import re
import socket
import struct
-from fqdn import FQDN
-
from jsonschema.exceptions import FormatError
@@ -211,16 +209,21 @@ if hasattr(socket, "inet_pton"):
return socket.inet_pton(socket.AF_INET6, instance)
-@_checks_drafts(
- draft3="host-name",
- draft4="hostname",
- draft6="hostname",
- draft7="hostname",
-)
-def is_host_name(instance):
- if not isinstance(instance, str):
- return True
- return FQDN(instance).is_valid
+try:
+ from fqdn import FQDN
+except ImportError:
+ pass
+else:
+ @_checks_drafts(
+ draft3="host-name",
+ draft4="hostname",
+ draft6="hostname",
+ draft7="hostname",
+ )
+ def is_host_name(instance):
+ if not isinstance(instance, str):
+ return True
+ return FQDN(instance).is_valid
try: