1010import types
1111import warnings
1212from collections import Counter , UserString
13+ from collections .abc import Callable , Collection , Iterator , Mapping , MutableMapping
1314from types import SimpleNamespace
14- from typing import (
15- Any ,
16- Callable ,
17- Collection ,
18- Dict ,
19- Generic ,
20- Iterator ,
21- List ,
22- Mapping ,
23- MutableMapping ,
24- NamedTuple ,
25- TypeVar ,
26- Union ,
27- overload ,
28- )
15+ from typing import Any , Generic , NamedTuple , TypeVar , Union , overload
2916from urllib .parse import quote as urlquote
3017from urllib .parse import urlsplit , urlunsplit
3118
@@ -184,7 +171,7 @@ def validate(self, value):
184171 return self .run_validation (value )
185172
186173
187- class ListOfItems (Generic [T ], BaseConfigOption [List [T ]]):
174+ class ListOfItems (Generic [T ], BaseConfigOption [list [T ]]):
188175 """
189176 Validates a homogeneous list of items.
190177
@@ -239,7 +226,7 @@ def run_validation(self, value: object) -> list[T]:
239226 return [fake_config [k ] for k in fake_keys ]
240227
241228
242- class DictOfItems (Generic [T ], BaseConfigOption [Dict [str , T ]]):
229+ class DictOfItems (Generic [T ], BaseConfigOption [dict [str , T ]]):
243230 """
244231 Validates a dict of items. Keys are always strings.
245232
@@ -942,7 +929,7 @@ def run_validation(self, value: object) -> ExtraScriptValue | str:
942929 return self .option_type .run_validation (value )
943930
944931
945- class MarkdownExtensions (OptionallyRequired [List [str ]]):
932+ class MarkdownExtensions (OptionallyRequired [list [str ]]):
946933 """
947934 Markdown Extensions Config Option.
948935
@@ -1078,8 +1065,7 @@ def _parse_configs(cls, value: list | tuple | dict) -> Iterator[tuple[str, dict]
10781065 def load_plugin_with_namespace (self , name : str , config ) -> tuple [str , plugins .BasePlugin ]:
10791066 if '/' in name : # It's already specified with a namespace.
10801067 # Special case: allow to explicitly skip namespaced loading:
1081- if name .startswith ('/' ):
1082- name = name [1 :]
1068+ name = name .removeprefix ('/' )
10831069 else :
10841070 # Attempt to load with prepended namespace for the current theme.
10851071 if self .theme_key and self ._config :
@@ -1155,7 +1141,7 @@ def load_plugin(self, name: str, config) -> plugins.BasePlugin:
11551141 return plugin
11561142
11571143
1158- class Hooks (BaseConfigOption [List [types .ModuleType ]]):
1144+ class Hooks (BaseConfigOption [list [types .ModuleType ]]):
11591145 """A list of Python scripts to be treated as instances of plugins."""
11601146
11611147 def __init__ (self , plugins_key : str ) -> None :
@@ -1177,7 +1163,7 @@ def run_validation(self, value: object) -> Mapping[str, Any]:
11771163 hooks [name ] = self ._load_hook (name , path )
11781164 return hooks
11791165
1180- @functools .lru_cache ( maxsize = None )
1166+ @functools .cache
11811167 def _load_hook (self , name , path ):
11821168 import importlib .util
11831169
0 commit comments