Skip to content

Commit 0b35a57

Browse files
Setup CI and linting (#17)
* added .pre-commit-config, added ruff config to pyproj, removed requirements.txt * adds daily test CI * 3.09 -> 3.9 nit
1 parent 2ac91ce commit 0b35a57

File tree

5 files changed

+134
-12
lines changed

5 files changed

+134
-12
lines changed

.github/workflows/main.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths-ignore:
7+
- 'docs/**'
8+
pull_request:
9+
branches: [ "main" ]
10+
paths-ignore:
11+
- 'docs/**'
12+
schedule: # every day at noon
13+
- cron: "0 12 * * *"
14+
env:
15+
UV_HTTP_TIMEOUT: 500
16+
17+
jobs:
18+
19+
test:
20+
name: ${{ matrix.python-version }}-build
21+
runs-on: ubuntu-latest
22+
defaults:
23+
run:
24+
shell: bash -l {0}
25+
strategy:
26+
matrix:
27+
python-version: ["3.9", "3.10", "3.11"]
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Setup Python
32+
id: setup-python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: Install uv
38+
run: |
39+
curl -LsSf https://astral.sh/uv/install.sh | sh
40+
uv venv .venv
41+
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
42+
43+
- name: Install cubed-xarray
44+
run: |
45+
uv pip install --system '.'
46+
uv pip install --system '.[test]'
47+
48+
- name: Running Tests
49+
run: |
50+
python -m pytest .

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# https://pre-commit.com/
2+
ci:
3+
autoupdate_schedule: monthly
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.6.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: check-yaml
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: "v0.5.6"
15+
hooks:
16+
# Run the linter.
17+
- id: ruff
18+
args: [ --fix ]
19+
# Run the formatter.
20+
- id: ruff-format
21+
22+
- repo: https://github.com/pre-commit/mirrors-mypy
23+
rev: v1.10.0
24+
hooks:
25+
- id: mypy
26+
exclude: "docs"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Interface for using [cubed](https://github.com/cubed-dev/cubed) with [xarray](ht
1111

1212
## Installation
1313

14-
Install via pip
14+
Install via pip
1515

1616
`pip install cubed-xarray`
1717

@@ -34,7 +34,7 @@ Xarray objects backed by cubed arrays can be created either by:
3434
In (2) and (3) the choice to use `cubed.Array` instead of `dask.array.Array` is made by passing the keyword argument `chunked_array_type='cubed'`.
3535
To pass arguments to the constructor of `cubed.Array` you should pass them via the dictionary `from_array_kwargs`, e.g. `from_array_kwargs={'spec': cubed.Spec(allowed_mem='2GB')}`.
3636

37-
If cubed and cubed-xarray are installed but dask is not, then specifying `chunked_array_type` is not necessary,
37+
If cubed and cubed-xarray are installed but dask is not, then specifying `chunked_array_type` is not necessary,
3838
as the entrypoints system will then default to the only chunked parallel backend available (i.e. cubed).
3939

4040
## Sharp Edges 🔪

pyproject.toml

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,22 @@ classifiers = [
2121
]
2222
requires-python = ">=3.9"
2323
dependencies = [
24-
"numpy >= 1.17",
24+
"numpy >= 1.17.1",
2525
"xarray >= 2024.02.0",
2626
"cubed >= 0.14.2",
2727
]
2828

29+
30+
31+
[project.optional-dependencies]
32+
test = [
33+
"pre-commit",
34+
"ruff",
35+
"pytest-mypy",
36+
"pytest-cov",
37+
"pytest"]
38+
39+
2940
[project.urls]
3041
homepage = "https://github.com/xarray-contrib/cubed-xarray"
3142
documentation = "https://github.com/xarray-contrib/cubed-xarray#readme"
@@ -50,9 +61,47 @@ fallback_version = "999"
5061
[tool.pytest.ini_options]
5162
junit_family = "xunit2"
5263

53-
[tool.isort]
54-
profile = "black"
55-
skip_gitignore = "true"
56-
force_to_top = "true"
57-
default_section = "THIRDPARTY"
58-
known_first_party = "cubed_xarray"
64+
65+
[mypy]
66+
files = "cubed_xarray/**/*.py"
67+
show_error_codes = true
68+
69+
[tool.ruff]
70+
# Same as Black.
71+
line-length = 88
72+
indent-width = 4
73+
target-version = "py39"
74+
75+
exclude = [
76+
"docs",
77+
".eggs"]
78+
79+
[tool.ruff.lint]
80+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
81+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
82+
# McCabe complexity (`C901`) by default.
83+
select = ["E4", "E7", "E9", "F", "I"]
84+
per-file-ignores = {}
85+
86+
# E402: module level import not at top of file
87+
# E731: do not assign a lambda expression, use a def
88+
# W503: line break before binary operator - not implimeted by ruff due to conflict with PEP8.
89+
90+
ignore = ["E402", "E731"]
91+
92+
# Allow fix for all enabled rules (when `--fix`) is provided.
93+
fixable = ["ALL"]
94+
unfixable = []
95+
96+
[tool.ruff.format]
97+
# Like Black, use double quotes for strings.
98+
quote-style = "double"
99+
# Indent with spaces, rather than tabs.
100+
indent-style = "space"
101+
# Respect magic trailing commas.
102+
skip-magic-trailing-comma = false
103+
# Automatically detect the appropriate line ending.
104+
line-ending = "auto"
105+
106+
[tool.ruff.lint.isort]
107+
known-first-party = ["cubed_xarray"]

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)