Skip to content

Commit fa8a690

Browse files
committed
address comments
1 parent 15e26dc commit fa8a690

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

pandas/io/pytables.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import re
1111
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
1313
import warnings
1414

1515
import numpy as np
@@ -916,8 +916,11 @@ def select_as_multiple(
916916
elif t.nrows != nrows:
917917
raise ValueError("all tables must have exactly the same nrows!")
918918

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+
919923
# axis is the concentration axes
920-
_tbls = cast(List[Table], tbls) # assured by check above
921924
axis = list({t.non_index_axes[0][0] for t in _tbls})[0]
922925

923926
def func(_start, _stop, _where):
@@ -1439,11 +1442,10 @@ def error(t):
14391442
if value is None:
14401443

14411444
_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+
):
14471449
pt = "frame_table"
14481450
tt = "generic_table"
14491451
else:
@@ -1452,8 +1454,9 @@ def error(t):
14521454
"nor a value are passed"
14531455
)
14541456
else:
1457+
_TYPE_MAP = {Series: "series", DataFrame: "frame"}
14551458
try:
1456-
pt = {Series: "series", DataFrame: "frame"}[type(value)]
1459+
pt = _TYPE_MAP[type(value)]
14571460
except KeyError:
14581461
raise error("_TYPE_MAP")
14591462

0 commit comments

Comments
 (0)