@@ -45,7 +45,7 @@ def vocab_type_name(url: str) -> str:
4545
4646
4747def has_types (items : Any ) -> List [str ]:
48- r = [] # type: List[str ]
48+ r : List [ str ] = [ ]
4949 if isinstance (items , MutableMapping ):
5050 if items ["type" ] == "https://w3id.org/cwl/salad#record" :
5151 return [items ["name" ]]
@@ -106,8 +106,9 @@ def block_code(self, code: str, info: Optional[str] = None) -> str:
106106 return text + ">" + html .escape (code , quote = self ._escape ) + "</code></pre>\n "
107107
108108
109- def markdown_list_hook (markdown , text , state ):
110- # type: (Markdown[str, Any], str, State) -> Tuple[str, State]
109+ def markdown_list_hook (
110+ markdown : "Markdown[str, Any]" , text : str , state : "State"
111+ ) -> Tuple [str , "State" ]:
111112 """Patches problematic Markdown lists for later HTML generation.
112113
113114 When a Markdown list with paragraphs not indented with the list
@@ -286,7 +287,8 @@ def __init__(self) -> None:
286287 self .toc = ""
287288 self .start_numbering = True
288289
289- def add_entry (self , thisdepth , title ): # type: (int, str) -> str
290+ def add_entry (self , thisdepth : int , title : str ) -> str :
291+ """Add an entry to the table of contents."""
290292 depth = len (self .numbering )
291293 if thisdepth < depth :
292294 self .toc += "</ol>"
@@ -390,12 +392,12 @@ def __init__(
390392 ) -> None :
391393 self .typedoc = StringIO ()
392394 self .toc = toc
393- self .subs = {} # type : Dict[str, str]
394- self .docParent = {} # type : Dict[str, List[str]]
395- self .docAfter = {} # type : Dict[str, List[str]]
396- self .rendered = set () # type : Set[str]
395+ self .subs : Dict [str , str ] = {}
396+ self .docParent : Dict [str , List [str ]] = {}
397+ self .docAfter : Dict [str , List [str ]] = {}
398+ self .rendered : Set [str ] = set ()
397399 self .redirects = redirects
398- self .title = None # type : Optional[str]
400+ self .title : Optional [str ] = None
399401 self .primitiveType = primitiveType
400402
401403 for t in j :
@@ -418,17 +420,15 @@ def __init__(
418420 metaschema_loader = get_metaschema ()[2 ]
419421 alltypes = extend_and_specialize (j , metaschema_loader )
420422
421- self .typemap = {} # type : Dict[str, Dict[str, str]]
422- self .uses = {} # type : Dict[str, List[Tuple[str, str]]]
423- self .record_refs = {} # type : Dict[str, List[str]]
423+ self .typemap : Dict [str , Dict [str , str ]] = {}
424+ self .uses : Dict [str , List [Tuple [str , str ]]] = {}
425+ self .record_refs : Dict [str , List [str ]] = {}
424426 for entry in alltypes :
425427 self .typemap [entry ["name" ]] = entry
426428 try :
427429 if entry ["type" ] == "record" :
428430 self .record_refs [entry ["name" ]] = []
429- fields = entry .get (
430- "fields" , []
431- ) # type: Union[str, List[Dict[str, str]]]
431+ fields : Union [str , List [Dict [str , str ]]] = entry .get ("fields" , [])
432432 if isinstance (fields , str ):
433433 raise KeyError ("record fields must be a list of mappings" )
434434 for f in fields : # type: Dict[str, str]
@@ -615,20 +615,20 @@ def extendsfrom(item: Dict[str, Any], ex: List[Dict[str, Any]]) -> None:
615615 f ["doc" ] = number_headings (self .toc , f ["doc" ])
616616
617617 doc = doc + "\n \n " + f ["doc" ]
618- plugins = [
618+ plugins : List [ "PluginName" ] = [
619619 "strikethrough" ,
620620 "footnotes" ,
621621 "table" ,
622622 "url" ,
623- ] # type: List[PluginName] # fix error Generic str != explicit Literals
623+ ]
624624 # if escape active, wraps literal HTML into '<p> {HTML} </p>'
625625 # we must pass it to both since 'MyRenderer' is predefined
626626 escape = False
627- markdown2html = create_markdown (
627+ markdown2html : "Markdown[str, Any]" = create_markdown (
628628 renderer = MyRenderer (escape = escape ),
629629 plugins = plugins ,
630630 escape = escape ,
631- ) # type: Markdown[str, Any]
631+ )
632632 markdown2html .before_parse_hooks .append (markdown_list_hook )
633633 doc = markdown2html (doc )
634634
0 commit comments