Skip to content

Commit feab4d0

Browse files
committed
MAINT: Expand lint for *.py
1 parent 6ac759d commit feab4d0

File tree

8 files changed

+23
-30
lines changed

8 files changed

+23
-30
lines changed

ci/lint.sh

+4-10
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@ source activate pandas
77
RET=0
88

99
if [ "$LINT" ]; then
10-
echo "Linting"
11-
for path in 'api' 'core' 'indexes' 'types' 'formats' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
12-
do
13-
echo "linting -> pandas/$path"
14-
flake8 pandas/$path --filename '*.py'
15-
if [ $? -ne "0" ]; then
16-
RET=1
17-
fi
18-
19-
done
10+
# pandas/rpy is deprecated and will be removed.
11+
# pandas/src is C code, so no need to search there.
12+
echo "Linting *.py"
13+
flake8 pandas --filename '*.py' --exclude pandas/rpy,pandas/src
2014
echo "Linting *.py DONE"
2115

2216
echo "Linting *.pyx"

pandas/core/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import warnings
77
import copy
88

9-
from pandas.compat import(
9+
from pandas.compat import (
1010
zip, range, long, lzip,
1111
callable, map
1212
)

pandas/core/internals.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,9 @@ def get_result(other):
11471147
def handle_error():
11481148

11491149
if raise_on_error:
1150+
# The 'detail' variable is defined in outer scope.
11501151
raise TypeError('Could not operate %s with block values %s' %
1151-
(repr(other), str(detail)))
1152+
(repr(other), str(detail))) # noqa
11521153
else:
11531154
# return the values
11541155
result = np.empty(values.shape, dtype='O')

pandas/io/parsers.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -2194,16 +2194,17 @@ def _handle_usecols(self, columns, usecols_key):
21942194
usecols_key is used if there are string usecols.
21952195
"""
21962196
if self.usecols is not None:
2197-
if any([isinstance(u, string_types) for u in self.usecols]):
2197+
if any([isinstance(usecol, string_types)
2198+
for usecol in self.usecols]):
21982199
if len(columns) > 1:
21992200
raise ValueError("If using multiple headers, usecols must "
22002201
"be integers.")
22012202
col_indices = []
2202-
for u in self.usecols:
2203-
if isinstance(u, string_types):
2204-
col_indices.append(usecols_key.index(u))
2203+
for usecol in self.usecols:
2204+
if isinstance(usecol, string_types):
2205+
col_indices.append(usecols_key.index(usecol))
22052206
else:
2206-
col_indices.append(u)
2207+
col_indices.append(usecol)
22072208
else:
22082209
col_indices = self.usecols
22092210

pandas/io/tests/parser/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import pandas.util.testing as tm
1818
from pandas import DataFrame, Series, Index, MultiIndex
1919
from pandas import compat
20-
from pandas.compat import(StringIO, BytesIO, PY3,
21-
range, lrange, u)
20+
from pandas.compat import (StringIO, BytesIO, PY3,
21+
range, lrange, u)
2222
from pandas.io.common import DtypeWarning, EmptyDataError, URLError
2323
from pandas.io.parsers import TextFileReader, TextParser
2424

pandas/msgpack/__init__.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# coding: utf-8
2-
# flake8: noqa
3-
4-
from pandas.msgpack._version import version
5-
from pandas.msgpack.exceptions import *
62

73
from collections import namedtuple
84

5+
from pandas.msgpack.exceptions import * # noqa
6+
from pandas.msgpack._version import version # noqa
7+
98

109
class ExtType(namedtuple('ExtType', 'code data')):
1110
"""ExtType represents ext type in msgpack."""
@@ -18,11 +17,10 @@ def __new__(cls, code, data):
1817
raise ValueError("code must be 0~127")
1918
return super(ExtType, cls).__new__(cls, code, data)
2019

20+
import os # noqa
2121

22-
import os
23-
from pandas.msgpack._packer import Packer
24-
from pandas.msgpack._unpacker import unpack, unpackb, Unpacker
25-
22+
from pandas.msgpack._packer import Packer # noqa
23+
from pandas.msgpack._unpacker import unpack, unpackb, Unpacker # noqa
2624

2725

2826
def pack(o, stream, **kwargs):

pandas/tests/indexes/test_base.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1576,11 +1576,10 @@ def test_string_index_repr(self):
15761576
# py3/py2 repr can differ because of "u" prefix
15771577
# which also affects to displayed element size
15781578

1579-
# suppress flake8 warnings
15801579
if PY3:
15811580
coerce = lambda x: x
15821581
else:
1583-
coerce = unicode
1582+
coerce = unicode # noqa
15841583

15851584
# short
15861585
idx = pd.Index(['a', 'bb', 'ccc'])

pandas/util/testing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from pandas.core.algorithms import take_1d
3636

3737
import pandas.compat as compat
38-
from pandas.compat import(
38+
from pandas.compat import (
3939
filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
4040
raise_with_traceback, httplib, is_platform_windows, is_platform_32bit,
4141
PY3

0 commit comments

Comments
 (0)