Skip to content

Commit 10c3e9b

Browse files
authored
Merge branch 'main' into inclusive
2 parents 3aa6402 + 67d0ee2 commit 10c3e9b

9 files changed

+64
-76
lines changed

.pre-commit-config.yaml

+5-24
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,12 @@ repos:
1414
- id: absolufy-imports
1515
name: absolufy-imports
1616
files: ^xarray/
17-
# This wants to go before isort & flake8
18-
- repo: https://github.com/PyCQA/autoflake
19-
rev: "v2.0.0"
17+
- repo: https://github.com/charliermarsh/ruff-pre-commit
18+
# Ruff version.
19+
rev: 'v0.0.237'
2020
hooks:
21-
- id: autoflake # isort should run before black as black sometimes tweaks the isort output
22-
args: ["--in-place", "--ignore-init-module-imports"]
23-
- repo: https://github.com/PyCQA/isort
24-
rev: 5.11.4
25-
hooks:
26-
- id: isort
27-
- repo: https://github.com/asottile/pyupgrade
28-
rev: v3.3.1
29-
hooks:
30-
- id: pyupgrade
31-
args:
32-
- "--py39-plus"
21+
- id: ruff
22+
args: ["--fix"]
3323
# https://github.com/python/black#version-control-integration
3424
- repo: https://github.com/psf/black
3525
rev: 22.12.0
@@ -43,15 +33,6 @@ repos:
4333
exclude: "generate_aggregations.py"
4434
additional_dependencies: ["black==22.12.0"]
4535
- id: blackdoc-autoupdate-black
46-
- repo: https://github.com/PyCQA/flake8
47-
rev: 6.0.0
48-
hooks:
49-
- id: flake8
50-
# - repo: https://github.com/Carreau/velin
51-
# rev: 0.0.8
52-
# hooks:
53-
# - id: velin
54-
# args: ["--write", "--compact"]
5536
- repo: https://github.com/pre-commit/mirrors-mypy
5637
rev: v0.991
5738
hooks:

ci/min_deps_check.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import sys
88
from collections.abc import Iterator
99
from datetime import datetime
10-
from typing import Optional
1110

1211
import conda.api # type: ignore[import]
1312
import yaml
@@ -45,7 +44,7 @@ def warning(msg: str) -> None:
4544
print("WARNING:", msg)
4645

4746

48-
def parse_requirements(fname) -> Iterator[tuple[str, int, int, Optional[int]]]:
47+
def parse_requirements(fname) -> Iterator[tuple[str, int, int, int | None]]:
4948
"""Load requirements/py37-min-all-deps.yml
5049
5150
Yield (package name, major version, minor version, [patch version])
@@ -116,7 +115,7 @@ def metadata(entry):
116115

117116

118117
def process_pkg(
119-
pkg: str, req_major: int, req_minor: int, req_patch: Optional[int]
118+
pkg: str, req_major: int, req_minor: int, req_patch: int | None
120119
) -> tuple[str, str, str, str, str, str]:
121120
"""Compare package version from requirements file to available versions in conda.
122121
Return row to build pandas dataframe:

pyproject.toml

+31
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,34 @@ module = [
6969
[[tool.mypy.overrides]]
7070
ignore_errors = true
7171
module = []
72+
73+
[tool.ruff]
74+
target-version = "py39"
75+
builtins = ["ellipsis"]
76+
exclude = [
77+
".eggs",
78+
"doc",
79+
"_typed_ops.pyi",
80+
]
81+
# E402: module level import not at top of file
82+
# E501: line too long - let black worry about that
83+
# E731: do not assign a lambda expression, use a def
84+
ignore = [
85+
"E402",
86+
"E501",
87+
"E731",
88+
]
89+
select = [
90+
# Pyflakes
91+
"F",
92+
# Pycodestyle
93+
"E",
94+
"W",
95+
# isort
96+
"I",
97+
# Pyupgrade
98+
"UP",
99+
]
100+
101+
[tool.ruff.isort]
102+
known-first-party = ["xarray"]

setup.cfg

-21
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,6 @@ markers =
145145
network: tests requiring a network connection
146146
slow: slow tests
147147

148-
[flake8]
149-
ignore =
150-
# E203: whitespace before ':' - doesn't work well with black
151-
# E402: module level import not at top of file
152-
# E501: line too long - let black worry about that
153-
# E731: do not assign a lambda expression, use a def
154-
# W503: line break before binary operator
155-
E203, E402, E501, E731, W503
156-
exclude =
157-
.eggs
158-
doc
159-
builtins =
160-
ellipsis
161-
162-
[isort]
163-
profile = black
164-
skip_gitignore = true
165-
float_to_top = true
166-
default_section = THIRDPARTY
167-
known_first_party = xarray
168-
169148
[aliases]
170149
test = pytest
171150

xarray/core/dataset.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@
2828

2929
from xarray.coding.calendar_ops import convert_calendar, interp_calendar
3030
from xarray.coding.cftimeindex import CFTimeIndex, _parse_array_of_cftime_strings
31-
from xarray.core import alignment
31+
from xarray.core import (
32+
alignment,
33+
duck_array_ops,
34+
formatting,
35+
formatting_html,
36+
ops,
37+
utils,
38+
)
3239
from xarray.core import dtypes as xrdtypes
33-
from xarray.core import duck_array_ops, formatting, formatting_html, ops, utils
3440
from xarray.core._aggregations import DatasetAggregations
3541
from xarray.core.alignment import (
3642
_broadcast_helper,

xarray/core/duck_array_ops.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
import pandas as pd
1717
from numpy import all as array_all # noqa
1818
from numpy import any as array_any # noqa
19-
from numpy import around # noqa
20-
from numpy import zeros_like # noqa
21-
from numpy import concatenate as _concatenate
2219
from numpy import ( # noqa
20+
around, # noqa
2321
einsum,
2422
gradient,
2523
isclose,
@@ -29,7 +27,9 @@
2927
tensordot,
3028
transpose,
3129
unravel_index,
30+
zeros_like, # noqa
3231
)
32+
from numpy import concatenate as _concatenate
3333
from numpy.lib.stride_tricks import sliding_window_view # noqa
3434

3535
from xarray.core import dask_array_ops, dtypes, nputils

xarray/tests/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def _importorskip(
101101
if has_dask:
102102
import dask
103103

104-
dask.config.set(scheduler="single-threaded")
105-
106104

107105
class CountingScheduler:
108106
"""Simple dask scheduler counting the number of computes.

xarray/tests/test_distributed.py

+14-19
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,53 @@
22
from __future__ import annotations
33

44
import pickle
5-
import numpy as np
6-
7-
from typing import Any, TYPE_CHECKING
5+
from typing import TYPE_CHECKING, Any
86

7+
import numpy as np
98
import pytest
109
from packaging.version import Version
1110

1211
if TYPE_CHECKING:
1312
import dask
13+
import dask.array as da
1414
import distributed
1515
else:
1616
dask = pytest.importorskip("dask")
17+
da = pytest.importorskip("dask.array")
1718
distributed = pytest.importorskip("distributed")
1819

1920
from dask.distributed import Client, Lock
2021
from distributed.client import futures_of
2122
from distributed.utils_test import ( # noqa: F401
23+
cleanup,
2224
cluster,
2325
gen_cluster,
2426
loop,
25-
cleanup,
2627
loop_in_thread,
2728
)
2829

2930
import xarray as xr
3031
from xarray.backends.locks import HDF5_LOCK, CombinedLock
31-
from xarray.tests.test_backends import (
32-
ON_WINDOWS,
33-
create_tmp_file,
34-
create_tmp_geotiff,
35-
open_example_dataset,
36-
)
37-
from xarray.tests.test_dataset import create_test_data
38-
3932
from xarray.tests import (
4033
assert_allclose,
4134
assert_identical,
4235
has_h5netcdf,
4336
has_netCDF4,
44-
requires_rasterio,
4537
has_scipy,
46-
requires_zarr,
4738
requires_cfgrib,
4839
requires_cftime,
4940
requires_netCDF4,
41+
requires_rasterio,
42+
requires_zarr,
5043
)
44+
from xarray.tests.test_backends import (
45+
ON_WINDOWS,
46+
create_tmp_file,
47+
create_tmp_geotiff,
48+
open_example_dataset,
49+
)
50+
from xarray.tests.test_dataset import create_test_data
5151

52-
# this is to stop isort throwing errors. May have been easier to just use
53-
# `isort:skip` in retrospect
54-
55-
56-
da = pytest.importorskip("dask.array")
5752
loop = loop # loop is an imported fixture, which flake8 has issues ack-ing
5853

5954

xarray/tests/test_ufuncs.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
import pytest
55

66
import xarray as xr
7-
from xarray.tests import assert_array_equal
7+
from xarray.tests import assert_array_equal, mock
88
from xarray.tests import assert_identical as assert_identical_
9-
from xarray.tests import mock
109

1110

1211
def assert_identical(a, b):

0 commit comments

Comments
 (0)