9
9
import os
10
10
import re
11
11
import time
12
- from typing import TYPE_CHECKING , Any , Dict , List , Optional , Type , Union , cast
12
+ from typing import TYPE_CHECKING , Any , Dict , List , Optional , Type , Union
13
13
import warnings
14
14
15
15
import numpy as np
@@ -916,8 +916,11 @@ def select_as_multiple(
916
916
elif t .nrows != nrows :
917
917
raise ValueError ("all tables must have exactly the same nrows!" )
918
918
919
+ # The isinstance checks here are redundant with the check above,
920
+ # but necessary for mypy; see GH#29757
921
+ _tbls = [x for x in tbls if isinstance (x , Table )]
922
+
919
923
# axis is the concentration axes
920
- _tbls = cast (List [Table ], tbls ) # assured by check above
921
924
axis = list ({t .non_index_axes [0 ][0 ] for t in _tbls })[0 ]
922
925
923
926
def func (_start , _stop , _where ):
@@ -1439,11 +1442,10 @@ def error(t):
1439
1442
if value is None :
1440
1443
1441
1444
_tables ()
1442
- # mypy can't tell that _table_mod is not None, so we have
1443
- # to do a type: ignore
1444
- cond1 = getattr (group , "table" , None )
1445
- cond2 = isinstance (group , _table_mod .table .Table ) # type: ignore
1446
- if cond1 or cond2 :
1445
+ assert _table_mod is not None # for mypy
1446
+ if getattr (group , "table" , None ) or isinstance (
1447
+ group , _table_mod .table .Table
1448
+ ):
1447
1449
pt = "frame_table"
1448
1450
tt = "generic_table"
1449
1451
else :
@@ -1452,8 +1454,9 @@ def error(t):
1452
1454
"nor a value are passed"
1453
1455
)
1454
1456
else :
1457
+ _TYPE_MAP = {Series : "series" , DataFrame : "frame" }
1455
1458
try :
1456
- pt = { Series : "series" , DataFrame : "frame" } [type (value )]
1459
+ pt = _TYPE_MAP [type (value )]
1457
1460
except KeyError :
1458
1461
raise error ("_TYPE_MAP" )
1459
1462
0 commit comments