@@ -19,6 +19,7 @@ from typing import (
1919 Generic ,
2020 Literal ,
2121 NoReturn ,
22+ TypeVar ,
2223 final ,
2324 overload ,
2425)
@@ -165,6 +166,8 @@ from pandas._typing import (
165166from pandas .io .formats .style import Styler
166167from pandas .plotting import PlotAccessor
167168
169+ _T_MUTABLE_MAPPING = TypeVar ("_T_MUTABLE_MAPPING" , bound = MutableMapping , covariant = True )
170+
168171class _iLocIndexerFrame (_iLocIndexer , Generic [_T ]):
169172 @overload
170173 def __getitem__ (self , idx : tuple [int , int ]) -> Scalar : ...
@@ -396,9 +399,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
396399 self ,
397400 orient : Literal ["records" ],
398401 * ,
399- into : MutableMapping | type [MutableMapping ],
402+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
400403 index : Literal [True ] = ...,
401- ) -> list [MutableMapping [ Hashable , Any ] ]: ...
404+ ) -> list [_T_MUTABLE_MAPPING ]: ...
402405 @overload
403406 def to_dict (
404407 self ,
@@ -412,33 +415,33 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
412415 self ,
413416 orient : Literal ["dict" , "list" , "series" , "index" ],
414417 * ,
415- into : MutableMapping | type [MutableMapping ],
418+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
416419 index : Literal [True ] = ...,
417- ) -> MutableMapping [ Hashable , Any ] : ...
420+ ) -> _T_MUTABLE_MAPPING : ...
418421 @overload
419422 def to_dict (
420423 self ,
421424 orient : Literal ["split" , "tight" ],
422425 * ,
423- into : MutableMapping | type [MutableMapping ],
426+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
424427 index : bool = ...,
425- ) -> MutableMapping [ Hashable , Any ] : ...
428+ ) -> _T_MUTABLE_MAPPING : ...
426429 @overload
427430 def to_dict (
428431 self ,
429432 orient : Literal ["dict" , "list" , "series" , "index" ] = ...,
430433 * ,
431- into : MutableMapping | type [MutableMapping ],
434+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
432435 index : Literal [True ] = ...,
433- ) -> MutableMapping [ Hashable , Any ] : ...
436+ ) -> _T_MUTABLE_MAPPING : ...
434437 @overload
435438 def to_dict (
436439 self ,
437440 orient : Literal ["split" , "tight" ] = ...,
438441 * ,
439- into : MutableMapping | type [MutableMapping ],
442+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
440443 index : bool = ...,
441- ) -> MutableMapping [ Hashable , Any ] : ...
444+ ) -> _T_MUTABLE_MAPPING : ...
442445 @overload
443446 def to_dict (
444447 self ,
0 commit comments