Skip to content

Commit 1021929

Browse files
authored
Merge pull request #26 from bcdev/forman-ruff
Using ruff
2 parents cbb7e70 + 95ecbe8 commit 1021929

File tree

88 files changed

+368
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+368
-491
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ jobs:
2626
python -m pip install --upgrade pip
2727
pip install .[dev,doc]
2828
29-
- name: Lint with flake8
29+
- name: Lint with ruff
3030
run: |
31-
# stop the build if there are Python syntax errors or undefined names
32-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
33-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
34-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31+
ruff check
3532
3633
- name: Run unit tests
3734
shell: bash -l {0}

.github/workflows/tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ jobs:
2929
run: |
3030
python -m pip install --upgrade pip
3131
pip install .[dev,doc]
32-
- name: Lint with flake8
32+
- name: Lint with ruff
3333
run: |
34-
# stop the build if there are Python syntax errors or undefined names
35-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34+
ruff check
3835
- name: Test with pytest
3936
run: |
4037
pytest --cov=xrlint --cov-branch --cov-report=xml

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
- Improved overall test coverage.
1818

19+
- Switched to [ruff](https://docs.astral.sh/ruff/)
20+
as default linter and formatter.
21+
1922

2023
## Version 0.2.0 (14.01.2025)
2124

CONTRIBUTING.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ checklist are addressed in your PR.
2020

2121
**PR checklist**
2222

23-
* Format code using [black](https://black.readthedocs.io/) with default settings.
24-
Check also section [code style](#code-style) below.
23+
* Format and check code using [ruff](https://docs.astral.sh/ruff/) with
24+
default settings: `ruff format` and `ruff check`. See also section
25+
[code style](#code-style) below.
2526
* Your change shall not break existing unit tests.
2627
`pytest` must run without errors.
2728
* Add unit tests for any new code not yet covered by tests.
@@ -33,16 +34,18 @@ checklist are addressed in your PR.
3334

3435
## Code style
3536

36-
The XRLint code complies to [PEP-8](https://pep8.org/) except for a line
37-
length of 88 characters as recommended by [black](https://black.readthedocs.io/).
38-
Since black is un-opinionated regarding the order of imports,
39-
we use the following three import blocks separated by an empty
40-
line:
37+
The code style of XRLint equals the default settings
38+
of [black](https://black.readthedocs.io/). Since black is
39+
un-opinionated regarding the order of imports, we group and
40+
sort imports statements according to the default settings of
41+
[isort](https://pycqa.github.io/isort/) which boils down to
4142

43+
0. Future imports
4244
1. Python standard library imports, e.g., `os`, `typing`, etc
4345
2. 3rd-party imports, e.g., `xarray`, `zarr`, etc
44-
3. XRLint module imports:
45-
Prefer absolute import paths: `from xrlint.a.b.c import d`.
46+
3. 1st-party XRLint module imports using absolute paths,
47+
e.g., `from xrlint.a.b.c import d`.
48+
4. 1st-party XRLint module imports from local modules:
4649
Relative imports such as `from .c import d` are ok
4750
while `..c import d` are not ok.
4851

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[![CI](https://github.com/bcdev/xrlint/actions/workflows/tests.yml/badge.svg)](https://github.com/bcdev/xrlint/actions/workflows/tests.yml)
22
[![codecov](https://codecov.io/gh/bcdev/xrlint/graph/badge.svg?token=GVKuJao97t)](https://codecov.io/gh/bcdev/xrlint)
33
[![PyPI Version](https://img.shields.io/pypi/v/xrlint)](https://pypi.org/project/xrlint/)
4-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5-
[![GitHub License](https://img.shields.io/github/license/bcdev/xrlint)](https://github.com/bcdev/xrlint)
4+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json)](https://github.com/charliermarsh/ruff)[![GitHub License](https://img.shields.io/github/license/bcdev/xrlint)](https://github.com/bcdev/xrlint)
65

76
# XRLint - A linter for xarray datasets
87

docs/about.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ pytest --cov=xrlint --cov-report html
5050

5151
### Code Style
5252

53-
XRLint source code is formatted using the [black](https://black.readthedocs.io/) tool and
54-
quality-controlled using [flake8](https://flake8.pycqa.org/).
53+
XRLint source code is formatted and quality-controlled using
54+
using [ruff](https://docs.astral.sh/ruff/):
5555

5656
```bash
57-
black .
58-
flake8 --max-line-length=88 .
57+
ruff format
58+
ruff check
5959
```
6060

6161
### Documentation

environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ dependencies:
1010
- tabulate
1111
- xarray
1212
# Dev Dependencies
13-
- black
14-
- flake8
1513
- mkdocs
1614
- mkdocs-autorefs
1715
- mkdocs-material
@@ -20,6 +18,7 @@ dependencies:
2018
- pytest
2119
- pytest-cov
2220
- requests-mock
21+
- ruff
2322
# Testing Datasets
2423
- pandas
2524
- netcdf4

examples/plugin_config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from xrlint.config import Config
77
from xrlint.node import DatasetNode
88
from xrlint.plugin import new_plugin
9-
from xrlint.rule import RuleContext
10-
from xrlint.rule import RuleOp
11-
9+
from xrlint.rule import RuleContext, RuleOp
1210

1311
plugin = new_plugin(
1412
name="hello-plugin",

examples/rule_testing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
import xarray as xr
66

77
from xrlint.node import DatasetNode
8-
from xrlint.rule import RuleContext
9-
from xrlint.rule import RuleOp
10-
from xrlint.rule import define_rule
11-
from xrlint.testing import RuleTest
12-
from xrlint.testing import RuleTester
8+
from xrlint.rule import RuleContext, RuleOp, define_rule
9+
from xrlint.testing import RuleTest, RuleTester
1310

1411

1512
@define_rule("good-title")

examples/virtual_plugin_config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"""
66

77
from xrlint.node import DatasetNode
8-
from xrlint.rule import RuleContext
9-
from xrlint.rule import RuleOp
10-
from xrlint.rule import define_rule
8+
from xrlint.rule import RuleContext, RuleOp, define_rule
119

1210

1311
@define_rule("good-title", description="Dataset title should be 'Hello World!'.")

0 commit comments

Comments
 (0)