From 26328d6c9dcab0695733f15b79703a0e642d5bc9 Mon Sep 17 00:00:00 2001 From: Gregory Rome Date: Mon, 6 May 2019 14:25:57 -0500 Subject: [PATCH 1/3] Add type annotations to core.computation --- mypy.ini | 9 --------- pandas/core/computation/expr.py | 3 ++- pandas/core/computation/ops.py | 3 ++- pandas/core/computation/pytables.py | 3 ++- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/mypy.ini b/mypy.ini index 63ccb6eb994ba..dad06ef38112a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,15 +11,6 @@ ignore_errors=True [mypy-pandas.core.base] ignore_errors=True -[mypy-pandas.core.computation.expr] -ignore_errors=True - -[mypy-pandas.core.computation.ops] -ignore_errors=True - -[mypy-pandas.core.computation.pytables] -ignore_errors=True - [mypy-pandas.core.config_init] ignore_errors=True diff --git a/pandas/core/computation/expr.py b/pandas/core/computation/expr.py index b697ada21f6b9..b87ef465459b4 100644 --- a/pandas/core/computation/expr.py +++ b/pandas/core/computation/expr.py @@ -7,6 +7,7 @@ import itertools as it import operator import tokenize +from typing import Type import numpy as np @@ -327,7 +328,7 @@ class BaseExprVisitor(ast.NodeVisitor): parser : str preparser : callable """ - const_type = Constant + const_type = Constant # type: Type[Term] term_type = Term binary_ops = _cmp_ops_syms + _bool_ops_syms + _arith_ops_syms diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index c604bf45a6598..493c7d8b146e8 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -166,7 +166,8 @@ def __init__(self, value, env, side=None, encoding=None): def _resolve_name(self): return self._name - @property + # read-only property overwriting read/write + @property # type: ignore def name(self): return self.value diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index 0a08123264fd7..7365eea26e005 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -56,7 +56,8 @@ def _resolve_name(self): except UndefinedVariableError: return self.name - @property + # read-only property overwriting read/write property + @property # type: ignore def value(self): return self._value From ce2b6863b2df4c09a5d793ee48def1a6559acab9 Mon Sep 17 00:00:00 2001 From: Gregory Rome Date: Mon, 6 May 2019 15:42:49 -0500 Subject: [PATCH 2/3] Re-trigger hung test From a618c543f7cd5c0bf3e3e4a39b779c1b66b7bca3 Mon Sep 17 00:00:00 2001 From: Gregory Rome Date: Tue, 7 May 2019 10:38:36 -0500 Subject: [PATCH 3/3] Remove Term.name setter and type annotation --- pandas/core/computation/ops.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index 493c7d8b146e8..a79b1d1e58977 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -149,10 +149,6 @@ def value(self, new_value): def name(self): return self._name - @name.setter - def name(self, new_name): - self._name = new_name - @property def ndim(self): return self._value.ndim @@ -166,8 +162,7 @@ def __init__(self, value, env, side=None, encoding=None): def _resolve_name(self): return self._name - # read-only property overwriting read/write - @property # type: ignore + @property def name(self): return self.value