5858from typing import (
5959 Any ,
6060 Callable ,
61+ Generic ,
6162 Iterable ,
6263 NamedTuple ,
6364 cast ,
6465)
6566import warnings
6667
67- from pandas ._typing import F
68+ from pandas ._typing import (
69+ F ,
70+ T ,
71+ )
6872
6973
7074class DeprecatedOption (NamedTuple ):
@@ -124,7 +128,7 @@ def _get_single_key(pat: str, silent: bool) -> str:
124128 return key
125129
126130
127- def _get_option (pat : str , silent : bool = False ):
131+ def _get_option (pat : str , silent : bool = False ) -> Any :
128132 key = _get_single_key (pat , silent )
129133
130134 # walk the nested dict
@@ -164,7 +168,7 @@ def _set_option(*args, **kwargs) -> None:
164168 o .cb (key )
165169
166170
167- def _describe_option (pat : str = "" , _print_desc : bool = True ):
171+ def _describe_option (pat : str = "" , _print_desc : bool = True ) -> str | None :
168172
169173 keys = _select_options (pat )
170174 if len (keys ) == 0 :
@@ -174,8 +178,8 @@ def _describe_option(pat: str = "", _print_desc: bool = True):
174178
175179 if _print_desc :
176180 print (s )
177- else :
178- return s
181+ return None
182+ return s
179183
180184
181185def _reset_option (pat : str , silent : bool = False ) -> None :
@@ -247,16 +251,17 @@ def __dir__(self) -> Iterable[str]:
247251# of options, and option descriptions.
248252
249253
250- class CallableDynamicDoc :
251- def __init__ (self , func , doc_tmpl ) -> None :
254+ class CallableDynamicDoc ( Generic [ T ]) :
255+ def __init__ (self , func : Callable [..., T ], doc_tmpl : str ) -> None :
252256 self .__doc_tmpl__ = doc_tmpl
253257 self .__func__ = func
254258
255- def __call__ (self , * args , ** kwds ):
259+ def __call__ (self , * args , ** kwds ) -> T :
256260 return self .__func__ (* args , ** kwds )
257261
262+ # error: Signature of "__doc__" incompatible with supertype "object"
258263 @property
259- def __doc__ (self ):
264+ def __doc__ (self ) -> str : # type: ignore[override]
260265 opts_desc = _describe_option ("all" , _print_desc = False )
261266 opts_list = pp_options_list (list (_registered_options .keys ()))
262267 return self .__doc_tmpl__ .format (opts_desc = opts_desc , opts_list = opts_list )
0 commit comments