58
58
from typing import (
59
59
Any ,
60
60
Callable ,
61
+ Generic ,
61
62
Iterable ,
62
63
NamedTuple ,
63
64
cast ,
64
65
)
65
66
import warnings
66
67
67
- from pandas ._typing import F
68
+ from pandas ._typing import (
69
+ F ,
70
+ T ,
71
+ )
68
72
69
73
70
74
class DeprecatedOption (NamedTuple ):
@@ -124,7 +128,7 @@ def _get_single_key(pat: str, silent: bool) -> str:
124
128
return key
125
129
126
130
127
- def _get_option (pat : str , silent : bool = False ):
131
+ def _get_option (pat : str , silent : bool = False ) -> Any :
128
132
key = _get_single_key (pat , silent )
129
133
130
134
# walk the nested dict
@@ -164,7 +168,7 @@ def _set_option(*args, **kwargs) -> None:
164
168
o .cb (key )
165
169
166
170
167
- def _describe_option (pat : str = "" , _print_desc : bool = True ):
171
+ def _describe_option (pat : str = "" , _print_desc : bool = True ) -> str | None :
168
172
169
173
keys = _select_options (pat )
170
174
if len (keys ) == 0 :
@@ -174,8 +178,8 @@ def _describe_option(pat: str = "", _print_desc: bool = True):
174
178
175
179
if _print_desc :
176
180
print (s )
177
- else :
178
- return s
181
+ return None
182
+ return s
179
183
180
184
181
185
def _reset_option (pat : str , silent : bool = False ) -> None :
@@ -247,16 +251,17 @@ def __dir__(self) -> Iterable[str]:
247
251
# of options, and option descriptions.
248
252
249
253
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 :
252
256
self .__doc_tmpl__ = doc_tmpl
253
257
self .__func__ = func
254
258
255
- def __call__ (self , * args , ** kwds ):
259
+ def __call__ (self , * args , ** kwds ) -> T :
256
260
return self .__func__ (* args , ** kwds )
257
261
262
+ # error: Signature of "__doc__" incompatible with supertype "object"
258
263
@property
259
- def __doc__ (self ):
264
+ def __doc__ (self ) -> str : # type: ignore[override]
260
265
opts_desc = _describe_option ("all" , _print_desc = False )
261
266
opts_list = pp_options_list (list (_registered_options .keys ()))
262
267
return self .__doc_tmpl__ .format (opts_desc = opts_desc , opts_list = opts_list )
0 commit comments