Skip to content

Commit 7fc3df5

Browse files
authored
Migrate flake8, isort, black rules to ruff (#49)
* Migrate flake8 rules to ruff Translating the previous flake8 rules in setup.cfg to ruff rules in pyproject.toml. Did not keep any of the ignored rules since none of them were triggered. Dropped the deprecated flake8-mypy (T4) rule. * Fix C419 unneccesary list-comprehension * Add flake8-simplify rule Xref https://docs.astral.sh/ruff/rules/#flake8-simplify-sim * Remove black and black-jupyter pre-commit hooks * Use ruff's built-in isort lint rule Xref https://docs.astral.sh/ruff/rules/#isort-i
1 parent c74ac17 commit 7fc3df5

File tree

4 files changed

+27
-33
lines changed

4 files changed

+27
-33
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,19 @@ repos:
2727
args:
2828
- "--py38-plus"
2929

30-
- repo: https://github.com/psf/black
31-
rev: 24.3.0
32-
hooks:
33-
- id: black
34-
- id: black-jupyter
35-
3630
- repo: https://github.com/keewis/blackdoc
3731
rev: v0.3.9
3832
hooks:
3933
- id: blackdoc
4034

41-
- repo: https://github.com/PyCQA/flake8
42-
rev: 7.0.0
43-
hooks:
44-
- id: flake8
45-
46-
- repo: https://github.com/PyCQA/isort
47-
rev: 5.13.2
35+
- repo: https://github.com/astral-sh/ruff-pre-commit
36+
rev: v0.4.10
4837
hooks:
49-
- id: isort
38+
- id: ruff
39+
types_or: [python, pyi, jupyter]
40+
args: [--fix]
41+
- id: ruff-format
42+
types_or: [python, pyi, jupyter]
5043

5144
- repo: https://github.com/pre-commit/mirrors-prettier
5245
rev: v4.0.0-alpha.8

cupy_xarray/accessors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def is_cupy(self):
127127
is_cupy: bool
128128
Whether the underlying data is a cupy array.
129129
"""
130-
return all([da.cupy.is_cupy for da in self.ds.data_vars.values()])
130+
return all(da.cupy.is_cupy for da in self.ds.data_vars.values())
131131

132132
def as_cupy(self):
133133
"""

pyproject.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
[tool.black]
2-
line-length = 100
3-
target-version = ['py38']
1+
[tool.ruff]
2+
line-length = 100 # E501 (line-too-long)
3+
exclude = [
4+
"docs",
5+
"versioneer.py",
6+
"cupy_xarray/_version.py",
7+
]
8+
9+
[tool.ruff.lint]
10+
select = [
11+
"B", # flake8-bugbear
12+
"C4", # flake8-comprehensions
13+
"C90", # mccabe
14+
"E", # pycodestyle
15+
"F", # pyflakes
16+
"I", # isort
17+
"SIM", # flake8-simplify
18+
"W", # pycodestyle warnings
19+
]

setup.cfg

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,3 @@ versionfile_source = cupy_xarray/_version.py
55
versionfile_build = cupy_xarray/_version.py
66
tag_prefix =
77
parentdir_prefix =
8-
9-
[flake8]
10-
exclude = docs,versioneer.py,cupy_xarray/_version.py
11-
ignore = E203,E266,E501,W503,E722,E402,C901,E731
12-
max-line-length = 100
13-
max-complexity = 18
14-
select = B,C,E,F,W,T4,B9
15-
16-
[isort]
17-
profile=black
18-
skip=
19-
docs/source/conf.py
20-
setup.py
21-
versioneer.py
22-
cupy_xarray/_version.py

0 commit comments

Comments
 (0)