11"""Common methods for parsing."""
22
3- import typing as T
3+ from typing import Any
44
55
66class ParseError (RuntimeError ):
@@ -19,7 +19,7 @@ class DocstringMeta:
1919 :raises ValueError: if something happens
2020 """
2121
22- def __init__ (self , args : T . List [str ], description : str ) -> None :
22+ def __init__ (self , args : list [str ], description : str ) -> None :
2323 """
2424 Initialize self.
2525
@@ -30,7 +30,7 @@ def __init__(self, args: T.List[str], description: str) -> None:
3030 self .description = description
3131
3232 @classmethod
33- def from_meta (cls , meta : "DocstringMeta" ) -> T . Any :
33+ def from_meta (cls , meta : "DocstringMeta" ) -> Any :
3434 """Copy DocstringMeta from another instance."""
3535 return cls (args = meta .args , description = meta .description )
3636
@@ -39,7 +39,7 @@ class DocstringTypeMeta(DocstringMeta):
3939 """Docstring meta whose only optional arg contains type information."""
4040
4141 @property
42- def type_name (self ) -> T . Optional [ str ] :
42+ def type_name (self ) -> str | None :
4343 """Return type name associated with given docstring metadata."""
4444 return self .args [1 ] if len (self .args ) > 1 else None
4545
@@ -48,7 +48,7 @@ class DocstringParam(DocstringMeta):
4848 """DocstringMeta symbolizing :param metadata."""
4949
5050 @property
51- def arg_name (self ) -> T . Optional [ str ] :
51+ def arg_name (self ) -> str | None :
5252 """Return argument name associated with given param."""
5353 if len (self .args ) > 2 :
5454 return self .args [2 ]
@@ -57,7 +57,7 @@ def arg_name(self) -> T.Optional[str]:
5757 return None
5858
5959 @property
60- def type_name (self ) -> T . Optional [ str ] :
60+ def type_name (self ) -> str | None :
6161 """Return type name associated with given param."""
6262 return self .args [1 ] if len (self .args ) > 2 else None
6363
@@ -78,7 +78,7 @@ class DocstringExamples(DocstringTypeMeta):
7878 """DocstringMeta symbolizing :examples metadata."""
7979
8080 @property
81- def name (self ) -> T . Optional [ str ] :
81+ def name (self ) -> str | None :
8282 """Return the example name associated with given param."""
8383 if self .args :
8484 return self .args [1 ]
@@ -90,14 +90,14 @@ class Docstring:
9090
9191 def __init__ (self ) -> None :
9292 """Initializes self."""
93- self .short_description = None # type: T.Optional[ str]
94- self .long_description = None # type: T.Optional[ str]
93+ self .short_description = None # type: str | None
94+ self .long_description = None # type: str | None
9595 self .blank_after_short_description = False
9696 self .blank_after_long_description = False
97- self .meta = [] # type: T.List [DocstringMeta]
97+ self .meta = [] # type: list [DocstringMeta]
9898
9999 @property
100- def params (self ) -> T . List [DocstringParam ]:
100+ def params (self ) -> list [DocstringParam ]:
101101 """Return parameters indicated in docstring."""
102102 return [
103103 DocstringParam .from_meta (meta )
@@ -107,7 +107,7 @@ def params(self) -> T.List[DocstringParam]:
107107 ]
108108
109109 @property
110- def raises (self ) -> T . List [DocstringRaises ]:
110+ def raises (self ) -> list [DocstringRaises ]:
111111 """Return exceptions indicated in docstring."""
112112 return [
113113 DocstringRaises .from_meta (meta )
@@ -116,7 +116,7 @@ def raises(self) -> T.List[DocstringRaises]:
116116 ]
117117
118118 @property
119- def returns (self ) -> T . Optional [ DocstringReturns ] :
119+ def returns (self ) -> DocstringReturns | None :
120120 """Return return information indicated in docstring."""
121121 try :
122122 return next (
@@ -128,7 +128,7 @@ def returns(self) -> T.Optional[DocstringReturns]:
128128 return None
129129
130130 @property
131- def examples (self ) -> T . Optional [ DocstringExamples ] :
131+ def examples (self ) -> DocstringExamples | None :
132132 """Return example information indicated in docstring."""
133133 return [
134134 DocstringExamples .from_meta (meta )
0 commit comments