Skip to content

Commit 668724b

Browse files
TYP: misc typing cleanup for core/computation/expressions.py (pandas-dev#36005)
1 parent 945a543 commit 668724b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pandas/core/computation/expressions.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
"""
88
import operator
9+
from typing import List, Set
910
import warnings
1011

1112
import numpy as np
@@ -21,7 +22,7 @@
2122
import numexpr as ne
2223

2324
_TEST_MODE = None
24-
_TEST_RESULT = None
25+
_TEST_RESULT: List[bool] = list()
2526
_USE_NUMEXPR = _NUMEXPR_INSTALLED
2627
_evaluate = None
2728
_where = None
@@ -75,7 +76,7 @@ def _can_use_numexpr(op, op_str, a, b, dtype_check):
7576
# required min elements (otherwise we are adding overhead)
7677
if np.prod(a.shape) > _MIN_ELEMENTS:
7778
# check for dtype compatibility
78-
dtypes = set()
79+
dtypes: Set[str] = set()
7980
for o in [a, b]:
8081
# Series implements dtypes, check for dimension count as well
8182
if hasattr(o, "dtypes") and o.ndim > 1:
@@ -247,25 +248,28 @@ def where(cond, a, b, use_numexpr=True):
247248
return _where(cond, a, b) if use_numexpr else _where_standard(cond, a, b)
248249

249250

250-
def set_test_mode(v=True):
251+
def set_test_mode(v: bool = True) -> None:
251252
"""
252-
Keeps track of whether numexpr was used. Stores an additional ``True``
253-
for every successful use of evaluate with numexpr since the last
254-
``get_test_result``
253+
Keeps track of whether numexpr was used.
254+
255+
Stores an additional ``True`` for every successful use of evaluate with
256+
numexpr since the last ``get_test_result``.
255257
"""
256258
global _TEST_MODE, _TEST_RESULT
257259
_TEST_MODE = v
258260
_TEST_RESULT = []
259261

260262

261-
def _store_test_result(used_numexpr):
263+
def _store_test_result(used_numexpr: bool) -> None:
262264
global _TEST_RESULT
263265
if used_numexpr:
264266
_TEST_RESULT.append(used_numexpr)
265267

266268

267-
def get_test_result():
268-
"""get test result and reset test_results"""
269+
def get_test_result() -> List[bool]:
270+
"""
271+
Get test result and reset test_results.
272+
"""
269273
global _TEST_RESULT
270274
res = _TEST_RESULT
271275
_TEST_RESULT = []

0 commit comments

Comments
 (0)