Skip to content

Commit 4ff91c9

Browse files
simonjayhawkinsjreback
authored andcommitted
TYP: check_untyped_defs core.computation.ops (#31366)
1 parent 5402ea5 commit 4ff91c9

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

pandas/core/computation/ops.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from distutils.version import LooseVersion
66
from functools import partial
77
import operator
8+
from typing import Callable, Iterable, Optional, Union
89

910
import numpy as np
1011

@@ -55,7 +56,7 @@ class UndefinedVariableError(NameError):
5556
NameError subclass for local variables.
5657
"""
5758

58-
def __init__(self, name, is_local: bool):
59+
def __init__(self, name: str, is_local: Optional[bool] = None):
5960
base_msg = f"{repr(name)} is not defined"
6061
if is_local:
6162
msg = f"local variable {base_msg}"
@@ -199,10 +200,10 @@ class Op:
199200

200201
op: str
201202

202-
def __init__(self, op: str, operands, *args, **kwargs):
203+
def __init__(self, op: str, operands: Iterable[Union[Term, "Op"]], encoding=None):
203204
self.op = _bool_op_map.get(op, op)
204205
self.operands = operands
205-
self.encoding = kwargs.get("encoding", None)
206+
self.encoding = encoding
206207

207208
def __iter__(self):
208209
return iter(self.operands)
@@ -353,11 +354,11 @@ class BinOp(Op):
353354
Parameters
354355
----------
355356
op : str
356-
left : Term or Op
357-
right : Term or Op
357+
lhs : Term or Op
358+
rhs : Term or Op
358359
"""
359360

360-
def __init__(self, op: str, lhs, rhs, **kwargs):
361+
def __init__(self, op: str, lhs, rhs):
361362
super().__init__(op, (lhs, rhs))
362363
self.lhs = lhs
363364
self.rhs = rhs
@@ -388,7 +389,6 @@ def __call__(self, env):
388389
object
389390
The result of an evaluated expression.
390391
"""
391-
392392
# recurse over the left/right nodes
393393
left = self.lhs(env)
394394
right = self.rhs(env)
@@ -416,13 +416,15 @@ def evaluate(self, env, engine: str, parser, term_type, eval_in_python):
416416
res = self(env)
417417
else:
418418
# recurse over the left/right nodes
419+
419420
left = self.lhs.evaluate(
420421
env,
421422
engine=engine,
422423
parser=parser,
423424
term_type=term_type,
424425
eval_in_python=eval_in_python,
425426
)
427+
426428
right = self.rhs.evaluate(
427429
env,
428430
engine=engine,
@@ -447,6 +449,7 @@ def convert_values(self):
447449
"""
448450

449451
def stringify(value):
452+
encoder: Callable
450453
if self.encoding is not None:
451454
encoder = partial(pprint_thing_encoded, encoding=self.encoding)
452455
else:
@@ -501,8 +504,8 @@ class Div(BinOp):
501504
The Terms or Ops in the ``/`` expression.
502505
"""
503506

504-
def __init__(self, lhs, rhs, **kwargs):
505-
super().__init__("/", lhs, rhs, **kwargs)
507+
def __init__(self, lhs, rhs):
508+
super().__init__("/", lhs, rhs)
506509

507510
if not isnumeric(lhs.return_type) or not isnumeric(rhs.return_type):
508511
raise TypeError(

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ check_untyped_defs=False
171171
[mypy-pandas.core.computation.expressions]
172172
check_untyped_defs=False
173173

174-
[mypy-pandas.core.computation.ops]
175-
check_untyped_defs=False
176-
177174
[mypy-pandas.core.computation.pytables]
178175
check_untyped_defs=False
179176

0 commit comments

Comments
 (0)