Skip to content

Commit

Permalink
One-off isort run (#3196)
Browse files Browse the repository at this point in the history
* One-off, manually vetted and tweaked isort run

* More isort tweaks

* Resilience to isort

* isort run

* Another isort run; fix sparse test

* Clean up unused imports
  • Loading branch information
crusaderky authored Aug 23, 2019
1 parent 55b33cd commit 79dc7dc
Show file tree
Hide file tree
Showing 34 changed files with 104 additions and 97 deletions.
1 change: 1 addition & 0 deletions asv_bench/benchmarks/combine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

import xarray as xr


Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ ignore=
E731
# line break before binary operator
W503
# Unused imports; TODO: Allow typing to work without triggering errors
F401
exclude=
doc

Expand Down
11 changes: 5 additions & 6 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@
from pathlib import Path
from textwrap import dedent
from typing import (
TYPE_CHECKING,
Callable,
Dict,
Hashable,
Iterable,
Mapping,
Tuple,
Union,
TYPE_CHECKING,
)

import numpy as np

from .. import Dataset, DataArray, backends, conventions, coding
from .. import DataArray, Dataset, auto_combine, backends, coding, conventions
from ..core import indexing
from .. import auto_combine
from ..core.combine import (
combine_by_coords,
_nested_combine,
_infer_concat_order_from_positions,
_nested_combine,
combine_by_coords,
)
from ..core.utils import close_on_error, is_grib_path, is_remote_uri
from .common import ArrayWriter, AbstractDataStore
from .common import AbstractDataStore, ArrayWriter
from .locks import _get_scheduler

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .. import Variable
from ..core import indexing
from ..core.utils import FrozenOrderedDict, close_on_error
from ..core.utils import FrozenOrderedDict
from .common import WritableCFDataStore
from .file_manager import CachingFileManager
from .locks import HDF5_LOCK, combine_locks, ensure_lock, get_write_lock
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .. import Variable, coding
from ..coding.variables import pop_to
from ..core import indexing
from ..core.utils import FrozenOrderedDict, close_on_error, is_remote_uri
from ..core.utils import FrozenOrderedDict, is_remote_uri
from .common import (
BackendArray,
WritableCFDataStore,
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import warnings
from collections import OrderedDict, defaultdict
from contextlib import suppress
from typing import Any, Dict, Hashable, Mapping, Optional, Tuple, Union, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict, Hashable, Mapping, Optional, Tuple, Union

import numpy as np
import pandas as pd
Expand All @@ -14,8 +14,8 @@
from .variable import IndexVariable, Variable

if TYPE_CHECKING:
from .dataarray import DataArray
from .dataset import Dataset
from .dataarray import DataArray # noqa: F401
from .dataset import Dataset # noqa: F401


def _get_joiner(join):
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import pandas as pd

from . import dtypes
from .concat import concat
from .dataarray import DataArray
from .dataset import Dataset
from .concat import concat
from . import dtypes
from .merge import merge


Expand Down
3 changes: 1 addition & 2 deletions xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections import Counter, OrderedDict
from distutils.version import LooseVersion
from typing import (
TYPE_CHECKING,
AbstractSet,
Any,
Callable,
Expand All @@ -17,7 +18,6 @@
Sequence,
Tuple,
Union,
TYPE_CHECKING,
)

import numpy as np
Expand Down Expand Up @@ -649,7 +649,6 @@ def func(*arrays):
def _apply_blockwise(
func, args, input_dims, output_dims, signature, output_dtypes, output_sizes=None
):
import dask.array as da
from .dask_array_compat import blockwise

if signature.num_outputs > 1:
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pandas as pd

from . import utils, dtypes
from . import dtypes, utils
from .alignment import align
from .variable import IndexVariable, Variable, as_variable
from .variable import concat as concat_vars
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
TYPE_CHECKING,
Any,
Hashable,
Mapping,
Iterator,
Union,
Mapping,
Sequence,
Set,
Tuple,
Sequence,
Union,
cast,
)

Expand Down
1 change: 0 additions & 1 deletion xarray/core/dask_array_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import numpy as np
from dask import __version__ as dask_version


try:
blockwise = da.blockwise
except AttributeError:
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collections import OrderedDict
from numbers import Number
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Expand All @@ -17,7 +18,6 @@
Union,
cast,
overload,
TYPE_CHECKING,
)

import numpy as np
Expand All @@ -38,9 +38,9 @@
from .accessor_dt import DatetimeAccessor
from .accessor_str import StringAccessor
from .alignment import (
align,
_broadcast_helper,
_get_broadcast_dims_map_common_coords,
align,
reindex_like_indexers,
)
from .common import AbstractArray, DataWithCoords
Expand All @@ -54,7 +54,7 @@
from .formatting import format_item
from .indexes import Indexes, default_indexes
from .options import OPTIONS
from .utils import _check_inplace, either_dict_or_kwargs, ReprObject
from .utils import ReprObject, _check_inplace, either_dict_or_kwargs
from .variable import (
IndexVariable,
Variable,
Expand Down
9 changes: 5 additions & 4 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from numbers import Number
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Callable,
DefaultDict,
Expand All @@ -24,14 +25,15 @@
Union,
cast,
overload,
TYPE_CHECKING,
)

import numpy as np
import pandas as pd

import xarray as xr

from ..coding.cftimeindex import _parse_array_of_cftime_strings
from ..plot.dataset_plot import _Dataset_PlotMethods
from . import (
alignment,
dtypes,
Expand All @@ -45,16 +47,16 @@
rolling,
utils,
)
from .alignment import align, _broadcast_helper, _get_broadcast_dims_map_common_coords
from .alignment import _broadcast_helper, _get_broadcast_dims_map_common_coords, align
from .common import (
ALL_DIMS,
DataWithCoords,
ImplementsDatasetReduce,
_contains_datetime_like_objects,
)
from .coordinates import (
DatasetCoordinates,
DataArrayCoordinates,
DatasetCoordinates,
LevelCoordinatesSource,
assert_coordinate_consistent,
remap_label_indexers,
Expand All @@ -79,7 +81,6 @@
maybe_wrap_array,
)
from .variable import IndexVariable, Variable, as_variable, broadcast_variables
from ..plot.dataset_plot import _Dataset_PlotMethods

if TYPE_CHECKING:
from ..backends import AbstractDataStore, ZarrStore
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from . import dask_array_ops, dtypes, npcompat, nputils
from .nputils import nanfirst, nanlast
from .pycompat import dask_array_type, sparse_array_type
from .pycompat import dask_array_type

try:
import dask.array as dask_array
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

from . import dtypes, duck_array_ops, nputils, ops, utils
from .arithmetic import SupportsArithmetic
from .concat import concat
from .common import ALL_DIMS, ImplementsArrayReduce, ImplementsDatasetReduce
from .concat import concat
from .options import _get_keep_attrs
from .pycompat import integer_types
from .utils import (
either_dict_or_kwargs,
hashable,
maybe_wrap_array,
peek_at,
safe_cast_to_index,
either_dict_or_kwargs,
)
from .variable import IndexVariable, Variable, as_variable

Expand Down
2 changes: 1 addition & 1 deletion xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import defaultdict
from contextlib import suppress
from datetime import timedelta
from typing import Any, Tuple, Sequence, Union
from typing import Any, Sequence, Tuple, Union

import numpy as np
import pandas as pd
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/merge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import OrderedDict
from typing import (
TYPE_CHECKING,
Any,
Dict,
Hashable,
Expand All @@ -11,7 +12,6 @@
Set,
Tuple,
Union,
TYPE_CHECKING,
)

import pandas as pd
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/npcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import builtins
import operator
from distutils.version import LooseVersion
from typing import Union

import operator
import numpy as np

try:
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/pdcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from distutils.version import LooseVersion

import numpy as np
import pandas as pd


# allow ourselves to type checks for Panel even after it's removed
if LooseVersion(pd.__version__) < "0.25.0":
Panel = pd.Panel
Expand Down
1 change: 0 additions & 1 deletion xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

from .pycompat import dask_array_type


K = TypeVar("K")
V = TypeVar("V")
T = TypeVar("T")
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import OrderedDict, defaultdict
from datetime import timedelta
from distutils.version import LooseVersion
from typing import Any, Hashable, Mapping, MutableMapping, Union
from typing import Any, Hashable, Mapping, Union

import numpy as np
import pandas as pd
Expand All @@ -18,9 +18,9 @@
VectorizedIndexer,
as_indexable,
)
from .npcompat import IS_NEP18_ACTIVE
from .options import _get_keep_attrs
from .pycompat import dask_array_type, integer_types
from .npcompat import IS_NEP18_ACTIVE
from .utils import (
OrderedSet,
decode_numpy_dict_values,
Expand Down
5 changes: 2 additions & 3 deletions xarray/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import numpy as np
import pandas as pd

from xarray.core import duck_array_ops
from xarray.core import formatting
from xarray.core import duck_array_ops, formatting
from xarray.core.dataarray import DataArray
from xarray.core.dataset import Dataset
from xarray.core.variable import IndexVariable, Variable
from xarray.core.indexes import default_indexes
from xarray.core.variable import IndexVariable, Variable


def _decode_string_data(data):
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib
import platform
import re
import warnings
from contextlib import contextmanager
Expand Down Expand Up @@ -32,7 +33,6 @@
except ImportError:
pass

import platform

arm_xfail = pytest.mark.xfail(
platform.machine() == "aarch64" or "arm" in platform.machine(),
Expand Down
Loading

0 comments on commit 79dc7dc

Please sign in to comment.