@@ -19,6 +19,7 @@ from typing import (
19
19
Generic ,
20
20
Literal ,
21
21
NoReturn ,
22
+ TypeVar ,
22
23
final ,
23
24
overload ,
24
25
)
@@ -165,6 +166,8 @@ from pandas._typing import (
165
166
from pandas .io .formats .style import Styler
166
167
from pandas .plotting import PlotAccessor
167
168
169
+ _T_MUTABLE_MAPPING = TypeVar ("_T_MUTABLE_MAPPING" , bound = MutableMapping , covariant = True )
170
+
168
171
class _iLocIndexerFrame (_iLocIndexer , Generic [_T ]):
169
172
@overload
170
173
def __getitem__ (self , idx : tuple [int , int ]) -> Scalar : ...
@@ -396,9 +399,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
396
399
self ,
397
400
orient : Literal ["records" ],
398
401
* ,
399
- into : MutableMapping | type [MutableMapping ],
402
+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
400
403
index : Literal [True ] = ...,
401
- ) -> list [MutableMapping [ Hashable , Any ] ]: ...
404
+ ) -> list [_T_MUTABLE_MAPPING ]: ...
402
405
@overload
403
406
def to_dict (
404
407
self ,
@@ -412,33 +415,33 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
412
415
self ,
413
416
orient : Literal ["dict" , "list" , "series" , "index" ],
414
417
* ,
415
- into : MutableMapping | type [MutableMapping ],
418
+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
416
419
index : Literal [True ] = ...,
417
- ) -> MutableMapping [ Hashable , Any ] : ...
420
+ ) -> _T_MUTABLE_MAPPING : ...
418
421
@overload
419
422
def to_dict (
420
423
self ,
421
424
orient : Literal ["split" , "tight" ],
422
425
* ,
423
- into : MutableMapping | type [MutableMapping ],
426
+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
424
427
index : bool = ...,
425
- ) -> MutableMapping [ Hashable , Any ] : ...
428
+ ) -> _T_MUTABLE_MAPPING : ...
426
429
@overload
427
430
def to_dict (
428
431
self ,
429
432
orient : Literal ["dict" , "list" , "series" , "index" ] = ...,
430
433
* ,
431
- into : MutableMapping | type [MutableMapping ],
434
+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
432
435
index : Literal [True ] = ...,
433
- ) -> MutableMapping [ Hashable , Any ] : ...
436
+ ) -> _T_MUTABLE_MAPPING : ...
434
437
@overload
435
438
def to_dict (
436
439
self ,
437
440
orient : Literal ["split" , "tight" ] = ...,
438
441
* ,
439
- into : MutableMapping | type [MutableMapping ],
442
+ into : _T_MUTABLE_MAPPING | type [_T_MUTABLE_MAPPING ],
440
443
index : bool = ...,
441
- ) -> MutableMapping [ Hashable , Any ] : ...
444
+ ) -> _T_MUTABLE_MAPPING : ...
442
445
@overload
443
446
def to_dict (
444
447
self ,
0 commit comments