123
123
is_sequence ,
124
124
pandas_dtype ,
125
125
)
126
+ from pandas .core .dtypes .dtypes import ExtensionDtype
126
127
from pandas .core .dtypes .missing import (
127
128
isna ,
128
129
notna ,
@@ -584,25 +585,17 @@ def __init__(
584
585
)
585
586
586
587
elif isinstance (data , dict ):
587
- # error: Argument "dtype" to "dict_to_mgr" has incompatible type
588
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]"; expected
589
- # "Union[dtype[Any], ExtensionDtype, None]"
590
- mgr = dict_to_mgr (
591
- data , index , columns , dtype = dtype , typ = manager # type: ignore[arg-type]
592
- )
588
+ mgr = dict_to_mgr (data , index , columns , dtype = dtype , typ = manager )
593
589
elif isinstance (data , ma .MaskedArray ):
594
590
import numpy .ma .mrecords as mrecords
595
591
596
592
# masked recarray
597
593
if isinstance (data , mrecords .MaskedRecords ):
598
- # error: Argument 4 to "rec_array_to_mgr" has incompatible type
599
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]"; expected
600
- # "Union[dtype[Any], ExtensionDtype, None]"
601
594
mgr = rec_array_to_mgr (
602
595
data ,
603
596
index ,
604
597
columns ,
605
- dtype , # type: ignore[arg-type]
598
+ dtype ,
606
599
copy ,
607
600
typ = manager ,
608
601
)
@@ -611,13 +604,10 @@ def __init__(
611
604
else :
612
605
data = sanitize_masked_array (data )
613
606
mgr = ndarray_to_mgr (
614
- # error: Argument "dtype" to "ndarray_to_mgr" has incompatible type
615
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]";
616
- # expected "Union[dtype[Any], ExtensionDtype, None]"
617
607
data ,
618
608
index ,
619
609
columns ,
620
- dtype = dtype , # type: ignore[arg-type]
610
+ dtype = dtype ,
621
611
copy = copy ,
622
612
typ = manager ,
623
613
)
@@ -626,14 +616,11 @@ def __init__(
626
616
if data .dtype .names :
627
617
# i.e. numpy structured array
628
618
629
- # error: Argument 4 to "rec_array_to_mgr" has incompatible type
630
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]"; expected
631
- # "Union[dtype[Any], ExtensionDtype, None]"
632
619
mgr = rec_array_to_mgr (
633
620
data ,
634
621
index ,
635
622
columns ,
636
- dtype , # type: ignore[arg-type]
623
+ dtype ,
637
624
copy ,
638
625
typ = manager ,
639
626
)
@@ -642,24 +629,18 @@ def __init__(
642
629
mgr = dict_to_mgr (
643
630
# error: Item "ndarray" of "Union[ndarray, Series, Index]" has no
644
631
# attribute "name"
645
- # error: Argument "dtype" to "dict_to_mgr" has incompatible type
646
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]";
647
- # expected "Union[dtype[Any], ExtensionDtype, None]"
648
632
{data .name : data }, # type: ignore[union-attr]
649
633
index ,
650
634
columns ,
651
- dtype = dtype , # type: ignore[arg-type]
635
+ dtype = dtype ,
652
636
typ = manager ,
653
637
)
654
638
else :
655
639
mgr = ndarray_to_mgr (
656
- # error: Argument "dtype" to "ndarray_to_mgr" has incompatible type
657
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]";
658
- # expected "Union[dtype[Any], ExtensionDtype, None]"
659
640
data ,
660
641
index ,
661
642
columns ,
662
- dtype = dtype , # type: ignore[arg-type]
643
+ dtype = dtype ,
663
644
copy = copy ,
664
645
typ = manager ,
665
646
)
@@ -680,46 +661,34 @@ def __init__(
680
661
arrays , columns , index = nested_data_to_arrays (
681
662
# error: Argument 3 to "nested_data_to_arrays" has incompatible
682
663
# type "Optional[Collection[Any]]"; expected "Optional[Index]"
683
- # error: Argument 4 to "nested_data_to_arrays" has incompatible
684
- # type "Union[ExtensionDtype, str, dtype[Any], Type[object],
685
- # None]"; expected "Union[dtype[Any], ExtensionDtype, None]"
686
664
data ,
687
665
columns ,
688
666
index , # type: ignore[arg-type]
689
- dtype , # type: ignore[arg-type]
667
+ dtype ,
690
668
)
691
669
mgr = arrays_to_mgr (
692
- # error: Argument "dtype" to "arrays_to_mgr" has incompatible
693
- # type "Union[ExtensionDtype, str, dtype[Any], Type[object],
694
- # None]"; expected "Union[dtype[Any], ExtensionDtype, None]"
695
670
arrays ,
696
671
columns ,
697
672
index ,
698
673
columns ,
699
- dtype = dtype , # type: ignore[arg-type]
674
+ dtype = dtype ,
700
675
typ = manager ,
701
676
)
702
677
else :
703
678
mgr = ndarray_to_mgr (
704
- # error: Argument "dtype" to "ndarray_to_mgr" has incompatible
705
- # type "Union[ExtensionDtype, str, dtype[Any], Type[object],
706
- # None]"; expected "Union[dtype[Any], ExtensionDtype, None]"
707
679
data ,
708
680
index ,
709
681
columns ,
710
- dtype = dtype , # type: ignore[arg-type]
682
+ dtype = dtype ,
711
683
copy = copy ,
712
684
typ = manager ,
713
685
)
714
686
else :
715
- # error: Argument "dtype" to "dict_to_mgr" has incompatible type
716
- # "Union[ExtensionDtype, str, dtype[Any], Type[object], None]"; expected
717
- # "Union[dtype[Any], ExtensionDtype, None]"
718
687
mgr = dict_to_mgr (
719
688
{},
720
689
index ,
721
690
columns ,
722
- dtype = dtype , # type: ignore[arg-type]
691
+ dtype = dtype ,
723
692
typ = manager ,
724
693
)
725
694
# For data is scalar
@@ -731,16 +700,11 @@ def __init__(
731
700
dtype , _ = infer_dtype_from_scalar (data , pandas_dtype = True )
732
701
733
702
# For data is a scalar extension dtype
734
- if is_extension_array_dtype (dtype ):
703
+ if isinstance (dtype , ExtensionDtype ):
735
704
# TODO(EA2D): special case not needed with 2D EAs
736
705
737
706
values = [
738
- # error: Argument 3 to "construct_1d_arraylike_from_scalar"
739
- # has incompatible type "Union[ExtensionDtype, str, dtype,
740
- # Type[object]]"; expected "Union[dtype, ExtensionDtype]"
741
- construct_1d_arraylike_from_scalar (
742
- data , len (index ), dtype # type: ignore[arg-type]
743
- )
707
+ construct_1d_arraylike_from_scalar (data , len (index ), dtype )
744
708
for _ in range (len (columns ))
745
709
]
746
710
mgr = arrays_to_mgr (
@@ -750,13 +714,10 @@ def __init__(
750
714
# error: Incompatible types in assignment (expression has type
751
715
# "ndarray", variable has type "List[ExtensionArray]")
752
716
values = construct_2d_arraylike_from_scalar ( # type: ignore[assignment]
753
- # error: Argument 4 to "construct_2d_arraylike_from_scalar" has
754
- # incompatible type "Union[ExtensionDtype, str, dtype[Any],
755
- # Type[object]]"; expected "dtype[Any]"
756
717
data ,
757
718
len (index ),
758
719
len (columns ),
759
- dtype , # type: ignore[arg-type]
720
+ dtype ,
760
721
copy ,
761
722
)
762
723
0 commit comments