From ffd99876e234b658d898505a1093a60146e4f5b7 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 4 Sep 2023 19:12:44 +0100 Subject: [PATCH] Revert "Lazy import urllib" This reverts commit a20f297b69fa9a14ee470077f702639fa69557e7. --- fastjsonschema/ref_resolver.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fastjsonschema/ref_resolver.py b/fastjsonschema/ref_resolver.py index a9b9eab..2a8816b 100644 --- a/fastjsonschema/ref_resolver.py +++ b/fastjsonschema/ref_resolver.py @@ -7,8 +7,11 @@ """ import contextlib +import json import re from urllib import parse as urlparse +from urllib.parse import unquote +from urllib.request import urlopen from .exceptions import JsonSchemaDefinitionException @@ -26,8 +29,6 @@ def resolve_path(schema, fragment): Path is unescaped according https://tools.ietf.org/html/rfc6901 """ - from urllib.parse import unquote - fragment = fragment.lstrip('/') parts = unquote(fragment).split('/') if fragment else [] for part in parts: @@ -54,9 +55,6 @@ def resolve_remote(uri, handlers): urllib library is used to fetch requests from the remote ``uri`` if handlers does notdefine otherwise. """ - import json - from urllib.request import urlopen - scheme = urlparse.urlsplit(uri).scheme if scheme in handlers: result = handlers[scheme](uri) @@ -151,8 +149,6 @@ def get_scope_name(self): """ Get current scope and return it as a valid function name. """ - from urllib.parse import unquote - name = 'validate_' + unquote(self.resolution_scope).replace('~1', '_').replace('~0', '_').replace('"', '') name = re.sub(r'($[^a-zA-Z]|[^a-zA-Z0-9])', '_', name) name = name.lower().rstrip('_')