Skip to content

Commit

Permalink
Add isort config (pandas-dev#23096)
Browse files Browse the repository at this point in the history
  • Loading branch information
alimcmaster1 authored and jreback committed Oct 17, 2018
1 parent e8d29e7 commit 9285820
Show file tree
Hide file tree
Showing 12 changed files with 659 additions and 135 deletions.
5 changes: 5 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime
RET=$(($RET + $?)) ; echo $MSG "DONE"

# Imports - Check formatting using isort see setup.cfg for settings
MSG='Check import format using isort ' ; echo $MSG
isort --recursive --check-only pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi

### PATTERNS ###
Expand Down
1 change: 1 addition & 0 deletions ci/environment-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- flake8
- flake8-comprehensions
- hypothesis>=3.58.0
- isort
- moto
- pytest>=3.6
- python-dateutil>=2.5.0
Expand Down
1 change: 1 addition & 0 deletions ci/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ NumPy
flake8
flake8-comprehensions
hypothesis>=3.58.0
isort
moto
pytest>=3.6
python-dateutil>=2.5.0
Expand Down
1 change: 1 addition & 0 deletions ci/travis-36.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
- geopandas
- html5lib
- ipython
- isort
- jinja2
- lxml
- matplotlib
Expand Down
22 changes: 8 additions & 14 deletions pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@

import numpy as np

import pandas.core.common as com
import pandas.core.indexes.base as ibase
from pandas import compat

from pandas._libs import index as libindex
from pandas.util._decorators import Appender, cache_readonly

from pandas.compat import lrange, range, get_range_parameters
from pandas.compat import get_range_parameters, lrange, range
from pandas.compat.numpy import function as nv

from pandas.core import ops
from pandas.core.dtypes import concat as _concat
from pandas.core.dtypes.common import (
is_integer,
is_scalar,
is_timedelta64_dtype,
is_int64_dtype)
is_int64_dtype, is_integer, is_scalar, is_timedelta64_dtype
)
from pandas.core.dtypes.generic import ABCSeries, ABCTimedeltaIndex
from pandas.core.dtypes import concat as _concat

import pandas.core.common as com
import pandas.core.indexes.base as ibase
from pandas.core import ops
from pandas.core.indexes.base import Index, _index_shared_docs
from pandas.core.indexes.numeric import Int64Index
from pandas.util._decorators import Appender, cache_readonly


class RangeIndex(Int64Index):
Expand Down
106 changes: 43 additions & 63 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,67 @@
"""
from __future__ import division

# pylint: disable=E1101,E1103
# pylint: disable=W0703,W0622,W0613,W0201

import warnings
from textwrap import dedent

import numpy as np
import numpy.ma as ma

import pandas.core.algorithms as algorithms
import pandas.core.common as com
import pandas.core.indexes.base as ibase
import pandas.core.nanops as nanops
import pandas.core.ops as ops
import pandas.io.formats.format as fmt
import pandas.plotting._core as gfx
from pandas import compat
from pandas._libs import iNaT, index as libindex, lib, tslibs
from pandas.compat import (
PY36, OrderedDict, StringIO, get_range_parameters, range, u, zip
)
from pandas.compat.numpy import function as nv
from pandas.core import base, generic
from pandas.core.accessor import CachedAccessor
from pandas.core.arrays import ExtensionArray
from pandas.core.arrays.categorical import Categorical, CategoricalAccessor
from pandas.core.config import get_option
from pandas.core.dtypes.cast import (
construct_1d_arraylike_from_scalar, construct_1d_ndarray_preserving_na,
construct_1d_object_array_from_listlike, infer_dtype_from_scalar,
maybe_cast_to_datetime, maybe_cast_to_integer_array, maybe_castable,
maybe_convert_platform, maybe_upcast
)
from pandas.core.dtypes.common import (
is_categorical_dtype,
is_string_like,
is_bool,
is_integer, is_integer_dtype,
is_float_dtype,
is_extension_type,
is_extension_array_dtype,
is_datetimelike,
is_datetime64tz_dtype,
is_timedelta64_dtype,
is_object_dtype,
is_list_like,
is_hashable,
is_iterator,
is_dict_like,
is_scalar,
_is_unorderable_exception,
ensure_platform_int,
pandas_dtype)
_is_unorderable_exception, ensure_platform_int, is_bool,
is_categorical_dtype, is_datetime64tz_dtype, is_datetimelike, is_dict_like,
is_extension_array_dtype, is_extension_type, is_float_dtype, is_hashable,
is_integer, is_integer_dtype, is_iterator, is_list_like, is_object_dtype,
is_scalar, is_string_like, is_timedelta64_dtype, pandas_dtype
)
from pandas.core.dtypes.generic import (
ABCSparseArray, ABCDataFrame, ABCIndexClass,
ABCSeries, ABCSparseSeries)
from pandas.core.dtypes.cast import (
maybe_upcast, infer_dtype_from_scalar,
maybe_convert_platform,
maybe_cast_to_datetime, maybe_castable,
construct_1d_arraylike_from_scalar,
construct_1d_ndarray_preserving_na,
construct_1d_object_array_from_listlike,
maybe_cast_to_integer_array)
ABCDataFrame, ABCIndexClass, ABCSeries, ABCSparseArray, ABCSparseSeries
)
from pandas.core.dtypes.missing import (
isna,
notna,
remove_na_arraylike,
na_value_for_dtype)

from pandas.core.index import (Index, MultiIndex, InvalidIndexError,
Float64Index, ensure_index)
from pandas.core.indexing import check_bool_indexer, maybe_convert_indices
from pandas.core import generic, base
from pandas.core.internals import SingleBlockManager
from pandas.core.arrays.categorical import Categorical, CategoricalAccessor
isna, na_value_for_dtype, notna, remove_na_arraylike
)
from pandas.core.index import (
Float64Index, Index, InvalidIndexError, MultiIndex, ensure_index
)
from pandas.core.indexes.accessors import CombinedDatetimelikeProperties
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.indexes.timedeltas import TimedeltaIndex
from pandas.core.indexes.period import PeriodIndex
from pandas import compat
from pandas.core.indexes.timedeltas import TimedeltaIndex
from pandas.core.indexing import check_bool_indexer, maybe_convert_indices
from pandas.core.internals import SingleBlockManager
from pandas.core.strings import StringMethods
from pandas.core.tools.datetimes import to_datetime
from pandas.io.formats.terminal import get_terminal_size
from pandas.compat import (
zip, u, OrderedDict, StringIO, range, get_range_parameters, PY36)
from pandas.compat.numpy import function as nv

import pandas.core.ops as ops
import pandas.core.algorithms as algorithms

import pandas.core.common as com
import pandas.core.nanops as nanops
import pandas.core.indexes.base as ibase

import pandas.io.formats.format as fmt
from pandas.util._decorators import Appender, deprecate, Substitution
from pandas.util._decorators import Appender, Substitution, deprecate
from pandas.util._validators import validate_bool_kwarg

from pandas._libs import index as libindex, tslibs, lib, iNaT
from pandas.core.config import get_option
from pandas.core.strings import StringMethods
from pandas.core.tools.datetimes import to_datetime
# pylint: disable=E1101,E1103
# pylint: disable=W0703,W0622,W0613,W0201

import pandas.plotting._core as gfx

__all__ = ['Series']

Expand Down
40 changes: 17 additions & 23 deletions pandas/io/packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,33 @@

import os
import warnings
from datetime import datetime, date, timedelta
from datetime import date, datetime, timedelta
from textwrap import dedent

import numpy as np
from dateutil.parser import parse

from pandas import compat
from pandas import (Timestamp, Period, Series, DataFrame, # noqa:F401
Index, MultiIndex, Float64Index, Int64Index,
Panel, RangeIndex, PeriodIndex, DatetimeIndex, NaT,
Categorical, CategoricalIndex, IntervalIndex, Interval,
TimedeltaIndex)

from pandas.util._move import (
BadMove as _BadMove,
move_into_mutable_buffer as _move_into_mutable_buffer,
from pandas import ( # noqa:F401
Categorical, CategoricalIndex, DataFrame, DatetimeIndex, Float64Index,
Index, Int64Index, Interval, IntervalIndex, MultiIndex, NaT, Panel, Period,
PeriodIndex, RangeIndex, Series, TimedeltaIndex, Timestamp, compat
)
from pandas.errors import PerformanceWarning

from pandas.compat import u, u_safe

from pandas.core.dtypes.common import (
is_categorical_dtype, is_object_dtype,
needs_i8_conversion, pandas_dtype)

from pandas.core import internals
from pandas.core.arrays import IntervalArray
from pandas.core.generic import NDFrame
from pandas.core.internals import BlockManager, make_block, _safe_reshape
from pandas.core.sparse.api import SparseSeries, SparseDataFrame
from pandas.core.arrays.sparse import BlockIndex, IntIndex
from pandas.io.common import get_filepath_or_buffer, _stringify_path
from pandas.io.msgpack import Unpacker as _Unpacker, Packer as _Packer, ExtType
from pandas.core.dtypes.common import (
is_categorical_dtype, is_object_dtype, needs_i8_conversion, pandas_dtype
)
from pandas.core.generic import NDFrame
from pandas.core.internals import BlockManager, _safe_reshape, make_block
from pandas.core.sparse.api import SparseDataFrame, SparseSeries
from pandas.errors import PerformanceWarning
from pandas.io.common import _stringify_path, get_filepath_or_buffer
from pandas.io.msgpack import ExtType, Packer as _Packer, Unpacker as _Unpacker
from pandas.util._move import (
BadMove as _BadMove, move_into_mutable_buffer as _move_into_mutable_buffer
)

# check which compression libs we have installed
try:
Expand Down
53 changes: 23 additions & 30 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,41 @@
import re
import time
import warnings

from datetime import datetime, date
from datetime import date, datetime
from distutils.version import LooseVersion

import numpy as np

from pandas import (Series, DataFrame, Panel, Index,
MultiIndex, Int64Index, isna, concat, to_datetime,
SparseSeries, SparseDataFrame, PeriodIndex,
DatetimeIndex, TimedeltaIndex)
from pandas import compat
import pandas.core.common as com
from pandas import (
DataFrame, DatetimeIndex, Index, Int64Index, MultiIndex, Panel,
PeriodIndex, Series, SparseDataFrame, SparseSeries, TimedeltaIndex, compat,
concat, isna, to_datetime
)
from pandas._libs import algos, lib, writers as libwriters
from pandas._libs.tslibs import timezones

from pandas.errors import PerformanceWarning
from pandas.compat import PY3, range, lrange, string_types, filter

from pandas.core.dtypes.common import (
is_list_like,
is_categorical_dtype,
is_timedelta64_dtype,
is_datetime64tz_dtype,
is_datetime64_dtype,
ensure_object,
ensure_int64,
ensure_platform_int)
from pandas.core.dtypes.missing import array_equivalent

from pandas.compat import PY3, filter, lrange, range, string_types
from pandas.core import config
import pandas.core.common as com
from pandas.core.algorithms import match, unique
from pandas.core.arrays.categorical import (Categorical,
_factorize_from_iterables)
from pandas.core.arrays.categorical import (
Categorical, _factorize_from_iterables
)
from pandas.core.arrays.sparse import BlockIndex, IntIndex
from pandas.core.base import StringMixin
from pandas.core.computation.pytables import Expr, maybe_expression
from pandas.core.config import get_option
from pandas.core.dtypes.common import (
ensure_int64, ensure_object, ensure_platform_int, is_categorical_dtype,
is_datetime64_dtype, is_datetime64tz_dtype, is_list_like,
is_timedelta64_dtype
)
from pandas.core.dtypes.missing import array_equivalent
from pandas.core.index import ensure_index
from pandas.core.internals import (BlockManager, make_block,
_block2d_to_blocknd,
_factor_indexer, _block_shape)
from pandas.core.arrays.sparse import BlockIndex, IntIndex

from pandas.core.internals import (
BlockManager, _block2d_to_blocknd, _block_shape, _factor_indexer,
make_block
)
from pandas.errors import PerformanceWarning
from pandas.io.common import _stringify_path
from pandas.io.formats.printing import adjoin, pprint_thing

Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/arrays/categorical/test_subclass.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

from pandas import Categorical

import pandas.util.testing as tm
from pandas import Categorical


class TestCategoricalSubclassing(object):
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/tslibs/test_liboffsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import pytest

from pandas import Timestamp

import pandas._libs.tslibs.offsets as liboffsets
from pandas import Timestamp
from pandas._libs.tslibs.offsets import roll_qtrday


Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

# flake8: noqa

from pandas.tseries.frequencies import infer_freq
import pandas.tseries.offsets as offsets
from pandas.tseries.frequencies import infer_freq
Loading

0 comments on commit 9285820

Please sign in to comment.