22
33import os
44import re
5- from typing import Dict , List , Mapping , Optional , Type , cast
5+ from typing import Dict , Mapping , Optional , Type , cast
66from urllib .parse import urlparse
77
88import docutils .nodes
1818from sphinx .application import Sphinx
1919from sphinxcontrib .serializinghtml import JSONHTMLBuilder
2020
21+ if version_info < (7 , 2 ):
22+ from sphinx .builders .html import JavaScript # type: ignore[attr-defined]
23+ from sphinx .builders .html import ( # type: ignore[attr-defined]
24+ Stylesheet as StyleSheet ,
25+ )
26+ else :
27+ from sphinx .builders .html ._assets import _CascadingStyleSheet as StyleSheet
28+ from sphinx .builders .html ._assets import _JavaScript as JavaScript
2129from . import (
2230 html_translator_mixin ,
2331 json_builder_serializing_implementation ,
@@ -62,9 +70,9 @@ def _get_html_builder(base_builder: Type[sphinx.builders.html.StandaloneHTMLBuil
6270
6371 class CustomHTMLBuilder (base_builder ): # type: ignore
6472 if version_info < (7 , 2 ):
65- css_files : List [ sphinx . builders . html . Stylesheet ]
73+ css_files : list [ StyleSheet ]
6674 else :
67- _css_files : List [ sphinx . builders . html . _assets . _CascadingStyleSheet ] # type: ignore[name-defined]
75+ _css_files : list [ StyleSheet ] # type: ignore[name-defined]
6876 theme : sphinx .theming .Theme
6977 templates : sphinx .jinja2glue .BuiltinTemplateLoader
7078
@@ -98,11 +106,11 @@ def init_js_files(self):
98106 excluded_scripts .add ("_static/jquery.js" )
99107 excluded_scripts .add ("_static/_sphinx_javascript_frameworks_compat.js" )
100108 if version_info < (7 , 2 ):
101- self .script_files : List [ sphinx . builders . html . JavaScript ] = [
109+ self .script_files : list [ JavaScript ] = [
102110 x for x in self .script_files if x .filename not in excluded_scripts
103111 ]
104112 else :
105- self ._js_files : List [ sphinx . builders . html . _assets . _JavaScript ] = [ # type: ignore[name-defined]
113+ self ._js_files : list [ JavaScript ] = [ # type: ignore[name-defined]
106114 x for x in self ._js_files if x .filename not in excluded_scripts
107115 ]
108116
@@ -121,14 +129,14 @@ def init_css_files(self):
121129 if version_info < (7 , 2 ):
122130 self .css_files = [
123131 x
124- for x in cast (List [ sphinx . builders . html . Stylesheet ], self .css_files )
132+ for x in cast (list [ StyleSheet ], self .css_files )
125133 if x .filename not in excluded
126134 ]
127135 else :
128136 self ._css_files = [
129137 x
130138 for x in cast (
131- List [ sphinx . builders . html . _assets . _CascadingStyleSheet ], # type: ignore[name-defined]
139+ list [ StyleSheet ], # type: ignore[name-defined]
132140 self ._css_files ,
133141 )
134142 if x .filename not in excluded
0 commit comments