Skip to content

Commit

Permalink
MAINT: Expand lint for *.py (pandas-dev#14516)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung authored and jorisvandenbossche committed Oct 28, 2016
1 parent d7fb5bd commit 096d886
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 30 deletions.
14 changes: 4 additions & 10 deletions ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ source activate pandas
RET=0

if [ "$LINT" ]; then
echo "Linting"
for path in 'api' 'core' 'indexes' 'types' 'formats' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
do
echo "linting -> pandas/$path"
flake8 pandas/$path --filename '*.py'
if [ $? -ne "0" ]; then
RET=1
fi

done
# pandas/rpy is deprecated and will be removed.
# pandas/src is C code, so no need to search there.
echo "Linting *.py"
flake8 pandas --filename '*.py' --exclude pandas/rpy,pandas/src
echo "Linting *.py DONE"

echo "Linting *.pyx"
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import warnings
import copy

from pandas.compat import(
from pandas.compat import (
zip, range, long, lzip,
callable, map
)
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,9 @@ def get_result(other):
def handle_error():

if raise_on_error:
# The 'detail' variable is defined in outer scope.
raise TypeError('Could not operate %s with block values %s' %
(repr(other), str(detail)))
(repr(other), str(detail))) # noqa
else:
# return the values
result = np.empty(values.shape, dtype='O')
Expand Down
10 changes: 5 additions & 5 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,16 +2194,16 @@ def _handle_usecols(self, columns, usecols_key):
usecols_key is used if there are string usecols.
"""
if self.usecols is not None:
if any([isinstance(u, string_types) for u in self.usecols]):
if any([isinstance(col, string_types) for col in self.usecols]):
if len(columns) > 1:
raise ValueError("If using multiple headers, usecols must "
"be integers.")
col_indices = []
for u in self.usecols:
if isinstance(u, string_types):
col_indices.append(usecols_key.index(u))
for col in self.usecols:
if isinstance(col, string_types):
col_indices.append(usecols_key.index(col))
else:
col_indices.append(u)
col_indices.append(col)
else:
col_indices = self.usecols

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/tests/parser/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import pandas.util.testing as tm
from pandas import DataFrame, Series, Index, MultiIndex
from pandas import compat
from pandas.compat import(StringIO, BytesIO, PY3,
range, lrange, u)
from pandas.compat import (StringIO, BytesIO, PY3,
range, lrange, u)
from pandas.io.common import DtypeWarning, EmptyDataError, URLError
from pandas.io.parsers import TextFileReader, TextParser

Expand Down
14 changes: 6 additions & 8 deletions pandas/msgpack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# coding: utf-8
# flake8: noqa

from pandas.msgpack._version import version
from pandas.msgpack.exceptions import *

from collections import namedtuple

from pandas.msgpack.exceptions import * # noqa
from pandas.msgpack._version import version # noqa


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

import os # noqa

import os
from pandas.msgpack._packer import Packer
from pandas.msgpack._unpacker import unpack, unpackb, Unpacker

from pandas.msgpack._packer import Packer # noqa
from pandas.msgpack._unpacker import unpack, unpackb, Unpacker # noqa


def pack(o, stream, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,11 +1576,10 @@ def test_string_index_repr(self):
# py3/py2 repr can differ because of "u" prefix
# which also affects to displayed element size

# suppress flake8 warnings
if PY3:
coerce = lambda x: x
else:
coerce = unicode
coerce = unicode # noqa

# short
idx = pd.Index(['a', 'bb', 'ccc'])
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from pandas.core.algorithms import take_1d

import pandas.compat as compat
from pandas.compat import(
from pandas.compat import (
filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
raise_with_traceback, httplib, is_platform_windows, is_platform_32bit,
PY3
Expand Down

0 comments on commit 096d886

Please sign in to comment.