Skip to content

Commit 032ed84

Browse files
TYP: check_untyped_defs core.computation.pytables (#36920)
1 parent 3a63fed commit 032ed84

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

pandas/core/computation/pytables.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class Term(ops.Term):
4242
env: PyTablesScope
4343

4444
def __new__(cls, name, env, side=None, encoding=None):
45-
klass = Constant if not isinstance(name, str) else cls
45+
if isinstance(name, str):
46+
klass = cls
47+
else:
48+
klass = Constant
4649
return object.__new__(klass)
4750

4851
def __init__(self, name, env: PyTablesScope, side=None, encoding=None):
@@ -83,6 +86,7 @@ class BinOp(ops.BinOp):
8386

8487
op: str
8588
queryables: Dict[str, Any]
89+
condition: Optional[str]
8690

8791
def __init__(self, op: str, lhs, rhs, queryables: Dict[str, Any], encoding):
8892
super().__init__(op, lhs, rhs)
@@ -184,10 +188,8 @@ def convert_value(self, v) -> "TermValue":
184188

185189
def stringify(value):
186190
if self.encoding is not None:
187-
encoder = partial(pprint_thing_encoded, encoding=self.encoding)
188-
else:
189-
encoder = pprint_thing
190-
return encoder(value)
191+
return pprint_thing_encoded(value, encoding=self.encoding)
192+
return pprint_thing(value)
191193

192194
kind = ensure_decoded(self.kind)
193195
meta = ensure_decoded(self.meta)
@@ -257,9 +259,11 @@ def __repr__(self) -> str:
257259
def invert(self):
258260
""" invert the filter """
259261
if self.filter is not None:
260-
f = list(self.filter)
261-
f[1] = self.generate_filter_op(invert=True)
262-
self.filter = tuple(f)
262+
self.filter = (
263+
self.filter[0],
264+
self.generate_filter_op(invert=True),
265+
self.filter[2],
266+
)
263267
return self
264268

265269
def format(self):

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ check_untyped_defs=False
157157
[mypy-pandas.core.computation.ops]
158158
check_untyped_defs=False
159159

160-
[mypy-pandas.core.computation.pytables]
161-
check_untyped_defs=False
162-
163160
[mypy-pandas.core.computation.scope]
164161
check_untyped_defs=False
165162

0 commit comments

Comments
 (0)