Skip to content

Commit 2769ebf

Browse files
jschendelmroeschke
authored andcommitted
CLN: Remove PY35 flag from pandas.compat (#26036)
1 parent 9d66bdf commit 2769ebf

File tree

3 files changed

+6
-70
lines changed

3 files changed

+6
-70
lines changed

pandas/compat/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
PY2 = sys.version_info[0] == 2
2727
PY3 = sys.version_info[0] >= 3
28-
PY35 = sys.version_info >= (3, 5)
2928
PY36 = sys.version_info >= (3, 6)
3029
PY37 = sys.version_info >= (3, 7)
3130
PYPY = platform.python_implementation() == 'PyPy'

pandas/core/computation/expr.py

+3-66
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010

1111
import numpy as np
1212

13-
from pandas.compat import lmap
13+
from pandas.compat import iteritems, lmap
1414

1515
import pandas as pd
16-
from pandas import compat
1716
from pandas.core import common as com
1817
from pandas.core.base import StringMixin
1918
from pandas.core.computation.common import (
@@ -301,7 +300,7 @@ def f(self, node, *args, **kwargs):
301300
def add_ops(op_classes):
302301
"""Decorator to add default implementation of ops."""
303302
def f(cls):
304-
for op_attr_name, op_class in compat.iteritems(op_classes):
303+
for op_attr_name, op_class in iteritems(op_classes):
305304
ops = getattr(cls, '{name}_ops'.format(name=op_attr_name))
306305
ops_map = getattr(cls, '{name}_op_nodes_map'.format(
307306
name=op_attr_name))
@@ -590,9 +589,7 @@ def visit_Attribute(self, node, **kwargs):
590589
raise ValueError("Invalid Attribute context {name}"
591590
.format(name=ctx.__name__))
592591

593-
def visit_Call_35(self, node, side=None, **kwargs):
594-
""" in 3.5 the starargs attribute was changed to be more flexible,
595-
#11097 """
592+
def visit_Call(self, node, side=None, **kwargs):
596593

597594
if isinstance(node.func, ast.Attribute):
598595
res = self.visit_Attribute(node.func)
@@ -641,58 +638,6 @@ def visit_Call_35(self, node, side=None, **kwargs):
641638

642639
return self.const_type(res(*new_args, **kwargs), self.env)
643640

644-
def visit_Call_legacy(self, node, side=None, **kwargs):
645-
646-
# this can happen with: datetime.datetime
647-
if isinstance(node.func, ast.Attribute):
648-
res = self.visit_Attribute(node.func)
649-
elif not isinstance(node.func, ast.Name):
650-
raise TypeError("Only named functions are supported")
651-
else:
652-
try:
653-
res = self.visit(node.func)
654-
except UndefinedVariableError:
655-
# Check if this is a supported function name
656-
try:
657-
res = FuncNode(node.func.id)
658-
except ValueError:
659-
# Raise original error
660-
raise
661-
662-
if res is None:
663-
raise ValueError("Invalid function call {func}"
664-
.format(func=node.func.id))
665-
if hasattr(res, 'value'):
666-
res = res.value
667-
668-
if isinstance(res, FuncNode):
669-
args = [self.visit(targ) for targ in node.args]
670-
671-
if node.starargs is not None:
672-
args += self.visit(node.starargs)
673-
674-
if node.keywords or node.kwargs:
675-
raise TypeError("Function \"{name}\" does not support keyword "
676-
"arguments".format(name=res.name))
677-
678-
return res(*args, **kwargs)
679-
680-
else:
681-
args = [self.visit(targ).value for targ in node.args]
682-
if node.starargs is not None:
683-
args += self.visit(node.starargs).value
684-
685-
keywords = {}
686-
for key in node.keywords:
687-
if not isinstance(key, ast.keyword):
688-
raise ValueError("keyword error in function call "
689-
"'{func}'".format(func=node.func.id))
690-
keywords[key.arg] = self.visit(key.value).value
691-
if node.kwargs is not None:
692-
keywords.update(self.visit(node.kwargs).value)
693-
694-
return self.const_type(res(*args, **keywords), self.env)
695-
696641
def translate_In(self, op):
697642
return op
698643

@@ -734,14 +679,6 @@ def visitor(x, y):
734679
return reduce(visitor, operands)
735680

736681

737-
# ast.Call signature changed on 3.5,
738-
# conditionally change which methods is named
739-
# visit_Call depending on Python version, #11097
740-
if compat.PY35:
741-
BaseExprVisitor.visit_Call = BaseExprVisitor.visit_Call_35
742-
else:
743-
BaseExprVisitor.visit_Call = BaseExprVisitor.visit_Call_legacy
744-
745682
_python_not_supported = frozenset(['Dict', 'BoolOp', 'In', 'NotIn'])
746683
_numexpr_supported_calls = frozenset(_reductions + _mathops)
747684

pandas/tests/io/test_pytables.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import pytest
1212

1313
from pandas.compat import (
14-
PY35, PY36, is_platform_little_endian, is_platform_windows, lrange)
14+
PY36, is_platform_little_endian, is_platform_windows, lrange)
1515
import pandas.util._test_decorators as td
1616

1717
from pandas.core.dtypes.common import is_categorical_dtype
@@ -4027,8 +4027,8 @@ def test_pytables_native_read(self, datapath):
40274027
d2 = store['detector/readout']
40284028
assert isinstance(d2, DataFrame)
40294029

4030-
@pytest.mark.skipif(PY35 and is_platform_windows(),
4031-
reason="native2 read fails oddly on windows / 3.5")
4030+
@pytest.mark.skipif(is_platform_windows(),
4031+
reason="native2 read fails oddly on windows")
40324032
def test_pytables_native2_read(self, datapath):
40334033
with ensure_clean_store(
40344034
datapath('io', 'data', 'legacy_hdf', 'pytables_native2.h5'),

0 commit comments

Comments
 (0)