Skip to content

TYP: check_untyped_defs core.computation.eval #30551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions pandas/core/computation/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import abc
from typing import Dict, Type

from pandas.core.computation.align import align_terms, reconstruct_object
from pandas.core.computation.ops import _mathops, _reductions
Expand Down Expand Up @@ -53,7 +54,7 @@ def convert(self) -> str:
"""
return printing.pprint_thing(self.expr)

def evaluate(self):
def evaluate(self) -> object:
"""
Run the engine on the expression.

Expand All @@ -62,7 +63,7 @@ def evaluate(self):

Returns
-------
obj : object
object
The result of the passed expression.
"""
if not self._is_aligned:
Expand Down Expand Up @@ -101,12 +102,6 @@ class NumExprEngine(AbstractEngine):

has_neg_frac = True

def __init__(self, expr):
super().__init__(expr)

def convert(self) -> str:
return str(super().convert())

def _evaluate(self):
import numexpr as ne

Expand All @@ -128,14 +123,14 @@ class PythonEngine(AbstractEngine):

has_neg_frac = False

def __init__(self, expr):
super().__init__(expr)

def evaluate(self):
return self.expr()

def _evaluate(self):
def _evaluate(self) -> None:
pass


_engines = {"numexpr": NumExprEngine, "python": PythonEngine}
_engines: Dict[str, Type[AbstractEngine]] = {
"numexpr": NumExprEngine,
"python": PythonEngine,
}
5 changes: 3 additions & 2 deletions pandas/core/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import tokenize
from typing import Optional
import warnings

from pandas._libs.lib import _no_default
Expand All @@ -17,7 +18,7 @@
from pandas.io.formats.printing import pprint_thing


def _check_engine(engine):
def _check_engine(engine: Optional[str]) -> str:
"""
Make sure a valid engine is passed.

Expand Down Expand Up @@ -168,7 +169,7 @@ def _check_for_locals(expr: str, stack_level: int, parser: str):
def eval(
expr,
parser="pandas",
engine=None,
engine: Optional[str] = None,
truediv=_no_default,
local_dict=None,
global_dict=None,
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ check_untyped_defs=False
[mypy-pandas.core.computation.align]
check_untyped_defs=False

[mypy-pandas.core.computation.eval]
check_untyped_defs=False

[mypy-pandas.core.computation.expr]
check_untyped_defs=False

Expand Down