@@ -103,13 +103,13 @@ def SubLoader(loader): # type: (Loader) -> Loader
103103 skip_schemas = loader .skip_schemas )
104104
105105class Fetcher (object ):
106- def fetch_text (self , url ): # type: (unicode ) -> unicode
106+ def fetch_text (self , url ): # type: (Text ) -> Text
107107 raise NotImplementedError ()
108108
109- def check_exists (self , url ): # type: (unicode ) -> bool
109+ def check_exists (self , url ): # type: (Text ) -> bool
110110 raise NotImplementedError ()
111111
112- def urljoin (self , base_url , url ): # type: (unicode, unicode ) -> unicode
112+ def urljoin (self , base_url , url ): # type: (Text, Text ) -> Text
113113 raise NotImplementedError ()
114114
115115
@@ -122,7 +122,7 @@ def __init__(self,
122122 self .session = session
123123
124124 def fetch_text (self , url ):
125- # type: (unicode ) -> unicode
125+ # type: (Text ) -> Text
126126 if url in self .cache :
127127 return self .cache [url ]
128128
@@ -152,7 +152,7 @@ def fetch_text(self, url):
152152 else :
153153 raise ValueError ('Unsupported scheme in url: %s' % url )
154154
155- def check_exists (self , url ): # type: (unicode ) -> bool
155+ def check_exists (self , url ): # type: (Text ) -> bool
156156 if url in self .cache :
157157 return True
158158
@@ -178,9 +178,9 @@ class Loader(object):
178178 def __init__ (self ,
179179 ctx , # type: ContextType
180180 schemagraph = None , # type: rdflib.graph.Graph
181- foreign_properties = None , # type: Set[unicode ]
182- idx = None , # type: Dict[unicode , Union[CommentedMap, CommentedSeq, unicode , None]]
183- cache = None , # type: Dict[unicode , Any]
181+ foreign_properties = None , # type: Set[Text ]
182+ idx = None , # type: Dict[Text , Union[CommentedMap, CommentedSeq, Text , None]]
183+ cache = None , # type: Dict[Text , Any]
184184 session = None , # type: requests.sessions.Session
185185 fetcher_constructor = None , # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher]
186186 skip_schemas = None # type: bool
@@ -239,29 +239,29 @@ def __init__(self,
239239 self .fetch_text = self .fetcher .fetch_text
240240 self .check_exists = self .fetcher .check_exists
241241
242- self .url_fields = set () # type: Set[unicode ]
243- self .scoped_ref_fields = {} # type: Dict[unicode , int]
244- self .vocab_fields = set () # type: Set[unicode ]
245- self .identifiers = [] # type: List[unicode ]
246- self .identity_links = set () # type: Set[unicode ]
247- self .standalone = None # type: Optional[Set[unicode ]]
248- self .nolinkcheck = set () # type: Set[unicode ]
249- self .vocab = {} # type: Dict[unicode, unicode ]
250- self .rvocab = {} # type: Dict[unicode, unicode ]
251- self .idmap = {} # type: Dict[unicode , Any]
252- self .mapPredicate = {} # type: Dict[unicode, unicode ]
253- self .type_dsl_fields = set () # type: Set[unicode ]
242+ self .url_fields = set () # type: Set[Text ]
243+ self .scoped_ref_fields = {} # type: Dict[Text , int]
244+ self .vocab_fields = set () # type: Set[Text ]
245+ self .identifiers = [] # type: List[Text ]
246+ self .identity_links = set () # type: Set[Text ]
247+ self .standalone = None # type: Optional[Set[Text ]]
248+ self .nolinkcheck = set () # type: Set[Text ]
249+ self .vocab = {} # type: Dict[Text, Text ]
250+ self .rvocab = {} # type: Dict[Text, Text ]
251+ self .idmap = {} # type: Dict[Text , Any]
252+ self .mapPredicate = {} # type: Dict[Text, Text ]
253+ self .type_dsl_fields = set () # type: Set[Text ]
254254
255255 self .add_context (ctx )
256256
257257 def expand_url (self ,
258- url , # type: unicode
259- base_url , # type: unicode
258+ url , # type: Text
259+ base_url , # type: Text
260260 scoped_id = False , # type: bool
261261 vocab_term = False , # type: bool
262262 scoped_ref = None # type: int
263263 ):
264- # type: (...) -> unicode
264+ # type: (...) -> Text
265265 if url in (u"@id" , u"@type" ):
266266 return url
267267
@@ -298,7 +298,7 @@ def expand_url(self,
298298 else :
299299 return url
300300
301- def _add_properties (self , s ): # type: (unicode ) -> None
301+ def _add_properties (self , s ): # type: (Text ) -> None
302302 for _ , _ , rng in self .graph .triples ((s , RDFS .range , None )):
303303 literal = ((six .text_type (rng ).startswith (
304304 u"http://www.w3.org/2001/XMLSchema#" ) and
@@ -309,11 +309,11 @@ def _add_properties(self, s): # type: (unicode) -> None
309309 self .url_fields .add (six .text_type (s ))
310310 self .foreign_properties .add (six .text_type (s ))
311311
312- def add_namespaces (self , ns ): # type: (Dict[unicode, unicode ]) -> None
312+ def add_namespaces (self , ns ): # type: (Dict[Text, Text ]) -> None
313313 self .vocab .update (ns )
314314
315315 def add_schemas (self , ns , base_url ):
316- # type: (Union[List[unicode ], unicode ], unicode ) -> None
316+ # type: (Union[List[Text ], Text ], Text ) -> None
317317 if self .skip_schemas :
318318 return
319319 for sch in aslist (ns ):
@@ -348,7 +348,7 @@ def add_schemas(self, ns, base_url):
348348 self .idx [six .text_type (s )] = None
349349
350350 def add_context (self , newcontext , baseuri = "" ):
351- # type: (ContextType, unicode ) -> None
351+ # type: (ContextType, Text ) -> None
352352 if bool (self .vocab ):
353353 raise validate .ValidationException (
354354 "Refreshing context that already has stuff in it" )
@@ -413,17 +413,17 @@ def add_context(self, newcontext, baseuri=""):
413413 _logger .debug ("vocab is %s" , self .vocab )
414414
415415 def resolve_ref (self ,
416- ref , # type: Union[CommentedMap, CommentedSeq, unicode ]
417- base_url = None , # type: unicode
416+ ref , # type: Union[CommentedMap, CommentedSeq, Text ]
417+ base_url = None , # type: Text
418418 checklinks = True # type: bool
419419 ):
420- # type: (...) -> Tuple[Union[CommentedMap, CommentedSeq, unicode , None], Dict[unicode , Any]]
420+ # type: (...) -> Tuple[Union[CommentedMap, CommentedSeq, Text , None], Dict[Text , Any]]
421421
422- lref = ref # type: Union[CommentedMap, CommentedSeq, unicode , None]
422+ lref = ref # type: Union[CommentedMap, CommentedSeq, Text , None]
423423 obj = None # type: Optional[CommentedMap]
424- resolved_obj = None # type: Optional[Union[CommentedMap, CommentedSeq, unicode ]]
424+ resolved_obj = None # type: Optional[Union[CommentedMap, CommentedSeq, Text ]]
425425 inc = False
426- mixin = None # type: Optional[Dict[unicode , Any]]
426+ mixin = None # type: Optional[Dict[Text , Any]]
427427
428428 if not base_url :
429429 base_url = file_uri (os .getcwd ()) + "/"
@@ -581,10 +581,10 @@ def _resolve_idmap(self,
581581 typeDSLregex = re .compile (ur"^([^[?]+)(\[\])?(\?)?$" )
582582
583583 def _type_dsl (self ,
584- t , # type: Union[unicode , Dict, List]
584+ t , # type: Union[Text , Dict, List]
585585 lc ,
586586 filename ):
587- # type: (...) -> Union[unicode , Dict[unicode, unicode ], List[Union[unicode , Dict[unicode, unicode ]]]]
587+ # type: (...) -> Union[Text , Dict[Text, Text ], List[Union[Text , Dict[Text, Text ]]]]
588588
589589 if not isinstance (t , (str , six .text_type )):
590590 return t
@@ -627,7 +627,7 @@ def _resolve_type_dsl(self,
627627 t , datum .lc .data [n ], document .lc .filename ))
628628 if isinstance (datum2 , CommentedSeq ):
629629 datum3 = CommentedSeq ()
630- seen = [] # type: List[unicode ]
630+ seen = [] # type: List[Text ]
631631 for i , item in enumerate (datum2 ):
632632 if isinstance (item , CommentedSeq ):
633633 for j , v in enumerate (item ):
@@ -647,7 +647,7 @@ def _resolve_type_dsl(self,
647647 document [d ] = datum2
648648
649649 def _resolve_identifier (self , document , loader , base_url ):
650- # type: (CommentedMap, Loader, unicode ) -> unicode
650+ # type: (CommentedMap, Loader, Text ) -> Text
651651 # Expand identifier field (usually 'id') to resolve scope
652652 for identifer in loader .identifiers :
653653 if identifer in document :
@@ -666,7 +666,7 @@ def _resolve_identifier(self, document, loader, base_url):
666666 return base_url
667667
668668 def _resolve_identity (self , document , loader , base_url ):
669- # type: (Dict[unicode , List[unicode ]], Loader, unicode ) -> None
669+ # type: (Dict[Text , List[Text ]], Loader, Text ) -> None
670670 # Resolve scope for identity fields (fields where the value is the
671671 # identity of a standalone node, such as enum symbols)
672672 for identifer in loader .identity_links :
@@ -680,7 +680,7 @@ def _resolve_identity(self, document, loader, base_url):
680680 n ]] = document [identifer ][n ]
681681
682682 def _normalize_fields (self , document , loader ):
683- # type: (Dict[unicode, unicode ], Loader) -> None
683+ # type: (Dict[Text, Text ], Loader) -> None
684684 # Normalize fields which are prefixed or full URIn to vocabulary terms
685685 for d in document :
686686 d2 = loader .expand_url (d , u"" , scoped_id = False , vocab_term = True )
@@ -689,9 +689,9 @@ def _normalize_fields(self, document, loader):
689689 del document [d ]
690690
691691 def _resolve_uris (self ,
692- document , # type: Dict[unicode , Union[unicode , List[unicode ]]]
692+ document , # type: Dict[Text , Union[Text , List[Text ]]]
693693 loader , # type: Loader
694- base_url # type: unicode
694+ base_url # type: Text
695695 ):
696696 # type: (...) -> None
697697 # Resolve remaining URLs based on document base
@@ -714,11 +714,11 @@ def _resolve_uris(self,
714714
715715 def resolve_all (self ,
716716 document , # type: Union[CommentedMap, CommentedSeq]
717- base_url , # type: unicode
718- file_base = None , # type: unicode
717+ base_url , # type: Text
718+ file_base = None , # type: Text
719719 checklinks = True # type: bool
720720 ):
721- # type: (...) -> Tuple[Union[CommentedMap, CommentedSeq, unicode , None], Dict[unicode , Any]]
721+ # type: (...) -> Tuple[Union[CommentedMap, CommentedSeq, Text , None], Dict[Text , Any]]
722722 loader = self
723723 metadata = CommentedMap () # type: CommentedMap
724724 if file_base is None :
@@ -840,7 +840,7 @@ def resolve_all(self,
840840
841841 return document , metadata
842842
843- def fetch (self , url , inject_ids = True ): # type: (unicode , bool) -> Any
843+ def fetch (self , url , inject_ids = True ): # type: (Text , bool) -> Any
844844 if url in self .idx :
845845 return self .idx [url ]
846846 try :
@@ -868,7 +868,7 @@ def fetch(self, url, inject_ids=True): # type: (unicode, bool) -> Any
868868 FieldType = TypeVar ('FieldType' , six .text_type , CommentedSeq , CommentedMap )
869869
870870 def validate_scoped (self , field , link , docid ):
871- # type: (unicode, unicode, unicode ) -> unicode
871+ # type: (Text, Text, Text ) -> Text
872872 split = urlparse .urlsplit (docid )
873873 sp = split .fragment .split (u"/" )
874874 n = self .scoped_ref_fields [field ]
@@ -892,7 +892,7 @@ def validate_scoped(self, field, link, docid):
892892 "Field `%s` references unknown identifier `%s`, tried %s" % (field , link , ", " .join (tried )))
893893
894894 def validate_link (self , field , link , docid , all_doc_ids ):
895- # type: (unicode , FieldType, unicode , Dict[Text, Text]) -> FieldType
895+ # type: (Text , FieldType, Text , Dict[Text, Text]) -> FieldType
896896 if field in self .nolinkcheck :
897897 return link
898898 if isinstance (link , (str , six .text_type )):
@@ -939,7 +939,7 @@ def getid(self, d): # type: (Any) -> Optional[Text]
939939 return None
940940
941941 def validate_links (self , document , base_url , all_doc_ids ):
942- # type: (Union[CommentedMap, CommentedSeq, unicode , None], unicode , Dict[Text, Text]) -> None
942+ # type: (Union[CommentedMap, CommentedSeq, Text , None], Text , Dict[Text, Text]) -> None
943943 docid = self .getid (document )
944944 if not docid :
945945 docid = base_url
0 commit comments