1111from contextlib import suppress
1212from pathlib import Path
1313from textwrap import dedent
14- from typing import TYPE_CHECKING , Any , Callable , Sequence , Union , cast
14+ from typing import TYPE_CHECKING , Any , Callable , Literal , Sequence , Union , cast
1515
1616from griffe .c3linear import c3linear_merge
1717from griffe .docstrings .parsers import Parser , parse
@@ -90,7 +90,7 @@ def __init__(
9090 lineno : int | None = None ,
9191 endlineno : int | None = None ,
9292 parent : Object | None = None ,
93- parser : Parser | None = None ,
93+ parser : Literal [ "google" , "numpy" , "sphinx" ] | Parser | None = None ,
9494 parser_options : dict [str , Any ] | None = None ,
9595 ) -> None :
9696 """Initialize the docstring.
@@ -107,7 +107,7 @@ def __init__(
107107 self .lineno : int | None = lineno
108108 self .endlineno : int | None = endlineno
109109 self .parent : Object | None = parent
110- self .parser : Parser | None = parser
110+ self .parser : Literal [ "google" , "numpy" , "sphinx" ] | Parser | None = parser
111111 self .parser_options : dict [str , Any ] = parser_options or {}
112112
113113 def __bool__ (self ) -> bool :
@@ -131,7 +131,11 @@ def parsed(self) -> list[DocstringSection]:
131131 """
132132 return self .parse ()
133133
134- def parse (self , parser : Parser | None = None , ** options : Any ) -> list [DocstringSection ]:
134+ def parse (
135+ self ,
136+ parser : Literal ["google" , "numpy" , "sphinx" ] | Parser | None = None ,
137+ ** options : Any ,
138+ ) -> list [DocstringSection ]:
135139 """Parse the docstring into structured data.
136140
137141 Parameters:
0 commit comments