Skip to content

Commit 742ed39

Browse files
max-sixtyshoyer
authored andcommitted
Enable python 3.5.0-3.5.2 (#2831)
* bump minimum python version to 3.5.3 * Revert "bump minimum python version to 3.5.3" This reverts commit 77553e1. * guard typing import block * attempt to set patch version to 3.5.0 * "Type" also needs a guard * move 3.5.0 to py35-min * guiard all TYPE_CHECKING with new global * missing import * when two lines become one * formatting * two steps forward, one step back * Consolidate variables * lint
1 parent 8126d3e commit 742ed39

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed

ci/requirements-py35-min.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: test_env
22
dependencies:
3-
- python=3.5
3+
- python=3.5.0
44
- pytest
55
- flake8
66
- mock

xarray/coding/cftime_offsets.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@
4141
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4242

4343
import re
44+
import typing
4445
from datetime import timedelta
4546
from functools import partial
46-
from typing import ClassVar, Optional
4747

4848
import numpy as np
4949

50+
from ..core.pycompat import TYPE_CHECKING
5051
from .cftimeindex import CFTimeIndex, _parse_iso8601_with_reso
5152
from .times import format_cftime_datetime
5253

54+
if TYPE_CHECKING:
55+
from typing import ClassVar, Optional
56+
5357

5458
def get_date_type(calendar):
5559
"""Return the cftime date type for a given calendar name."""

xarray/core/computation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44
import functools
55
import itertools
66
import operator
7+
import typing
78
from collections import Counter, OrderedDict
89
from distutils.version import LooseVersion
910
from typing import (
1011
AbstractSet, Any, Callable, Iterable, List, Mapping, Optional, Sequence,
11-
Tuple, TYPE_CHECKING, Union,
12-
)
12+
Tuple, Union)
1313

1414
import numpy as np
1515

1616
from . import duck_array_ops, utils
1717
from .alignment import deep_align
1818
from .merge import expand_and_merge_variables
19-
from .pycompat import dask_array_type
19+
from .pycompat import TYPE_CHECKING, dask_array_type
2020
from .utils import is_dict_like
2121
from .variable import Variable
22+
2223
if TYPE_CHECKING:
2324
from .dataset import Dataset
2425

xarray/core/dataarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import numpy as np
66
import pandas as pd
77

8+
from ..plot.plot import _PlotMethods
89
from . import (
910
computation, dtypes, groupby, indexing, ops, resample, rolling, utils)
10-
from ..plot.plot import _PlotMethods
1111
from .accessors import DatetimeAccessor
1212
from .alignment import align, reindex_like_indexers
1313
from .common import AbstractArray, DataWithCoords

xarray/core/dataset.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
import copy
22
import functools
33
import sys
4+
import typing
45
import warnings
56
from collections import OrderedDict, defaultdict
67
from collections.abc import Mapping
78
from distutils.version import LooseVersion
89
from numbers import Number
910
from typing import (
10-
Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar, TYPE_CHECKING,
11-
Union,
12-
)
11+
Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar, Union)
1312

1413
import numpy as np
1514
import pandas as pd
1615

1716
import xarray as xr
1817

18+
from ..coding.cftimeindex import _parse_array_of_cftime_strings
1919
from . import (
2020
alignment, dtypes, duck_array_ops, formatting, groupby, indexing, ops,
2121
pdcompat, resample, rolling, utils)
22-
from ..coding.cftimeindex import _parse_array_of_cftime_strings
2322
from .alignment import align
2423
from .common import (
2524
ALL_DIMS, DataWithCoords, ImplementsDatasetReduce,
2625
_contains_datetime_like_objects)
2726
from .coordinates import (
2827
DatasetCoordinates, LevelCoordinatesSource, assert_coordinate_consistent,
29-
remap_label_indexers,
30-
)
28+
remap_label_indexers)
3129
from .duck_array_ops import datetime_to_numeric
3230
from .indexes import Indexes, default_indexes, isel_variable_and_index
3331
from .merge import (
3432
dataset_merge_method, dataset_update_method, merge_data_and_coords,
3533
merge_variables)
3634
from .options import OPTIONS, _get_keep_attrs
37-
from .pycompat import dask_array_type
35+
from .pycompat import TYPE_CHECKING, dask_array_type
3836
from .utils import (
39-
Frozen, SortedKeysDict, _check_inplace,
40-
decode_numpy_dict_values, either_dict_or_kwargs, ensure_us_time_resolution,
41-
hashable, maybe_wrap_array)
37+
Frozen, SortedKeysDict, _check_inplace, decode_numpy_dict_values,
38+
either_dict_or_kwargs, ensure_us_time_resolution, hashable, is_dict_like,
39+
maybe_wrap_array)
4240
from .variable import IndexVariable, Variable, as_variable, broadcast_variables
41+
4342
if TYPE_CHECKING:
4443
from .dataarray import DataArray
4544

xarray/core/merge.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
import typing
12
from collections import OrderedDict
2-
3-
from typing import (
4-
Any, Dict, List, Mapping, Optional, Set, Tuple, TYPE_CHECKING, Union,
5-
)
3+
from typing import Any, Dict, List, Mapping, Optional, Set, Tuple, Union
64

75
import pandas as pd
86

97
from .alignment import deep_align
8+
from .pycompat import TYPE_CHECKING
109
from .utils import Frozen
1110
from .variable import (
1211
Variable, as_variable, assert_unique_multiindex_level_names)
12+
1313
if TYPE_CHECKING:
1414
from .dataset import Dataset
1515

16+
1617
PANDAS_TYPES = (pd.Series, pd.DataFrame, pd.Panel)
1718

1819
_VALID_COMPAT = Frozen({'identical': 0,

xarray/core/pycompat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# flake8: noqa
2+
import sys
3+
import typing
24

35
import numpy as np
46

@@ -10,3 +12,7 @@
1012
dask_array_type = (dask.array.Array,)
1113
except ImportError: # pragma: no cover
1214
dask_array_type = ()
15+
16+
# Ensure we have some more recent additions to the typing module.
17+
# Note that TYPE_CHECKING itself is not available on Python 3.5.1.
18+
TYPE_CHECKING = sys.version >= '3.5.3' and typing.TYPE_CHECKING

xarray/core/variable.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import functools
22
import itertools
3+
import typing
34
from collections import OrderedDict, defaultdict
45
from datetime import timedelta
5-
from typing import Tuple, Type, Union
66

77
import numpy as np
88
import pandas as pd
@@ -15,9 +15,14 @@
1515
BasicIndexer, OuterIndexer, PandasIndexAdapter, VectorizedIndexer,
1616
as_indexable)
1717
from .options import _get_keep_attrs
18-
from .pycompat import dask_array_type, integer_types
19-
from .utils import (OrderedSet, either_dict_or_kwargs,
20-
decode_numpy_dict_values, ensure_us_time_resolution)
18+
from .pycompat import TYPE_CHECKING, dask_array_type, integer_types
19+
from .utils import (
20+
OrderedSet, decode_numpy_dict_values, either_dict_or_kwargs,
21+
ensure_us_time_resolution)
22+
23+
if TYPE_CHECKING:
24+
from typing import Tuple, Type, Union
25+
2126

2227
try:
2328
import dask.array as da

0 commit comments

Comments
 (0)