1010import sys
1111from collections .abc import Iterator
1212from dataclasses import dataclass
13- from typing import Any , Optional , TypedDict , Union
13+ from typing import Any , TypedDict
1414
1515import requests
1616import yaml
4242"""
4343
4444
45- def htmlElementReplace (lookup : str , presentation : Optional [ str ] = None ) -> str :
45+ def htmlElementReplace (lookup : str , presentation : str | None = None ) -> str :
4646 """
4747 Replace text in an HTML reference
4848 """
@@ -54,7 +54,7 @@ def htmlElementReplace(lookup: str, presentation: Optional[str] = None) -> str:
5454 return f"[{ presentation } ]({ url } )"
5555
5656
57- def glossaryReplace (lookup : str , presentation : Optional [ str ] = None ) -> str :
57+ def glossaryReplace (lookup : str , presentation : str | None = None ) -> str :
5858 """
5959 Replace text in a glossary reference
6060 """
@@ -66,7 +66,7 @@ def glossaryReplace(lookup: str, presentation: Optional[str] = None) -> str:
6666 return f"[{ presentation } ]({ url } )"
6767
6868
69- def cssXrefReplace (lookup : str , presentation : Optional [ str ] = None ) -> str :
69+ def cssXrefReplace (lookup : str , presentation : str | None = None ) -> str :
7070 """
7171 Replace text for CSS cross reference lookup
7272 """
@@ -78,7 +78,7 @@ def cssXrefReplace(lookup: str, presentation: Optional[str] = None) -> str:
7878 return f"[{ presentation } ]({ url } )"
7979
8080
81- def domXrefReplace (lookup : str , presentation : Optional [ str ] = None ) -> str :
81+ def domXrefReplace (lookup : str , presentation : str | None = None ) -> str :
8282 """
8383 Replace text for DOM cross reference lookup
8484 """
@@ -137,7 +137,7 @@ class TagsYmlItem(TypedDict):
137137 skip : NotRequired [bool ]
138138 """Whether to skip this tag when generating tags"""
139139
140- attributes : NotRequired [dict [str , Union [ str , AttrYmlItem ] ]]
140+ attributes : NotRequired [dict [str , str | AttrYmlItem ]]
141141 """Mapping of attributes used by the tag (name: description)"""
142142
143143 base : NotRequired [str ]
@@ -175,7 +175,7 @@ class Attr:
175175 Name of the attribute
176176 """
177177
178- doc : Optional [ str ]
178+ doc : str | None
179179 """
180180 Documentation of the attribute if applicable
181181 """
@@ -185,7 +185,7 @@ class Attr:
185185 Type to accept for the attribute
186186 """
187187
188- default : Optional [ Any ]
188+ default : Any | None
189189 """
190190 Default value for the attribute
191191 """
@@ -227,12 +227,12 @@ class TagInfo:
227227 List of attributes and their documentation.
228228 """
229229
230- pre_content : Optional [ str ]
230+ pre_content : str | None
231231 """
232232 Pre-content for the element (eg `<!DOCTYPE html>`)
233233 """
234234
235- render_options : Optional [ RenderOptions ]
235+ render_options : RenderOptions | None
236236 """
237237 Render options
238238 """
@@ -419,8 +419,8 @@ def attr_entries_to_object(tags: TagsYaml, tag_name: str) -> list[Attr]:
419419 attrs = []
420420 for name , value in tag_data ["attributes" ].items ():
421421 if isinstance (value , str ):
422- doc : Optional [ str ] = value
423- default : Optional [ str ] = None
422+ doc : str | None = value
423+ default : str | None = None
424424 type = "AttributeType"
425425 else :
426426 doc = value .get ("doc" )
@@ -479,7 +479,7 @@ def get_tag_escape_children(tags: TagsYaml, tag_name: str) -> bool:
479479 return tag .get ("escape_children" , True )
480480
481481
482- def get_tag_pre_content (tags : TagsYaml , tag_name : str ) -> Optional [ str ] :
482+ def get_tag_pre_content (tags : TagsYaml , tag_name : str ) -> str | None :
483483 """
484484 Return pre-content for the tag
485485 """
@@ -491,7 +491,7 @@ def get_tag_pre_content(tags: TagsYaml, tag_name: str) -> Optional[str]:
491491
492492def get_tag_render_options (
493493 tags : TagsYaml , tag_name : str
494- ) -> Optional [ RenderOptions ] :
494+ ) -> RenderOptions | None :
495495 """
496496 Return pre-content for the tag
497497 """
0 commit comments