22
33import functools
44import pathlib
5- from typing import List , Optional , Tuple
65
76import sphinx
87import sphinx .util
@@ -66,7 +65,7 @@ def __init__(
6665 This is the same as the fully qualified name of the object.
6766 """
6867
69- self .children : List [PythonObject ] = []
68+ self .children : list [PythonObject ] = []
7069 """The members of this object.
7170
7271 For example, the classes and functions defined in the parent module.
@@ -79,7 +78,7 @@ def __init__(
7978
8079 # For later
8180 self ._class_content = class_content
82- self ._display_cache : Optional [ bool ] = None
81+ self ._display_cache : bool | None = None
8382
8483 def __getstate__ (self ):
8584 """Obtains serialisable data for pickling."""
@@ -248,7 +247,7 @@ def _ask_ignore(self, skip: bool) -> bool:
248247
249248 return ask_result if ask_result is not None else skip
250249
251- def _children_of_type (self , type_ : str ) -> List [PythonObject ]:
250+ def _children_of_type (self , type_ : str ) -> list [PythonObject ]:
252251 return list (child for child in self .children if child .type == type_ )
253252
254253
@@ -268,20 +267,20 @@ def __init__(self, *args, **kwargs):
268267 self .args : str = _format_args (self .obj ["args" ], show_annotations )
269268 """The arguments to this object, formatted as a string."""
270269
271- self .return_annotation : Optional [ str ] = (
270+ self .return_annotation : str | None = (
272271 self .obj ["return_annotation" ] if show_annotations else None
273272 )
274273 """The type annotation for the return type of this function.
275274
276275 This will be ``None`` if an annotation
277276 or annotation comment was not given.
278277 """
279- self .properties : List [str ] = self .obj ["properties" ]
278+ self .properties : list [str ] = self .obj ["properties" ]
280279 """The properties that describe what type of function this is.
281280
282281 Can be only be: async.
283282 """
284- self .overloads : List [ Tuple [str , str ]] = [
283+ self .overloads : list [ tuple [str , str ]] = [
285284 (_format_args (args ), return_annotation )
286285 for args , return_annotation in self .obj ["overloads" ]
287286 ]
@@ -300,7 +299,7 @@ class PythonMethod(PythonFunction):
300299 def __init__ (self , * args , ** kwargs ):
301300 super ().__init__ (* args , ** kwargs )
302301
303- self .properties : List [str ] = self .obj ["properties" ]
302+ self .properties : list [str ] = self .obj ["properties" ]
304303 """The properties that describe what type of method this is.
305304
306305 Can be any of: abstractmethod, async, classmethod, property, staticmethod.
@@ -322,9 +321,9 @@ class PythonProperty(PythonObject):
322321 def __init__ (self , * args , ** kwargs ):
323322 super ().__init__ (* args , ** kwargs )
324323
325- self .annotation : Optional [ str ] = self .obj ["return_annotation" ]
324+ self .annotation : str | None = self .obj ["return_annotation" ]
326325 """The type annotation of this property."""
327- self .properties : List [str ] = self .obj ["properties" ]
326+ self .properties : list [str ] = self .obj ["properties" ]
328327 """The properties that describe what type of property this is.
329328
330329 Can be any of: abstractmethod, classmethod.
@@ -340,12 +339,12 @@ class PythonData(PythonObject):
340339 def __init__ (self , * args , ** kwargs ):
341340 super ().__init__ (* args , ** kwargs )
342341
343- self .value : Optional [ str ] = self .obj .get ("value" )
342+ self .value : str | None = self .obj .get ("value" )
344343 """The value of this attribute.
345344
346345 This will be ``None`` if the value is not constant.
347346 """
348- self .annotation : Optional [ str ] = self .obj .get ("annotation" )
347+ self .annotation : str | None = self .obj .get ("annotation" )
349348 """The type annotation of this attribute.
350349
351350 This will be ``None`` if an annotation
@@ -424,7 +423,7 @@ class PythonClass(PythonObject):
424423 def __init__ (self , * args , ** kwargs ):
425424 super ().__init__ (* args , ** kwargs )
426425
427- self .bases : List [str ] = self .obj ["bases" ]
426+ self .bases : list [str ] = self .obj ["bases" ]
428427 """The fully qualified names of all base classes."""
429428
430429 self ._docstring_resolved : bool = False
@@ -447,7 +446,7 @@ def args(self) -> str:
447446 return args
448447
449448 @property
450- def overloads (self ) -> List [ Tuple [str , str ]]:
449+ def overloads (self ) -> list [ tuple [str , str ]]:
451450 overloads = []
452451
453452 if self .constructor :
@@ -503,7 +502,7 @@ def classes(self):
503502 return self ._children_of_type ("class" )
504503
505504 @property
506- @functools .lru_cache ()
505+ @functools .lru_cache
507506 def constructor (self ):
508507 for child in self .children :
509508 if child .short_name == "__init__" :
0 commit comments