Skip to content

Commit fa62c2d

Browse files
Armavicadcheriankeewis
authored
Add prettier and pygrep hooks to pre-commit hooks (pydata#9644)
* Fix code touching text * Fix type ignore syntax * Use type annotations instead of comments * Fix code with two backticks in rst files * Add pygrep-hooks pre-commit * Fix typos in docs and code * Add prettier pre-commit hook * Apply suggestions from code review * Update .pre-commit-config.yaml Co-authored-by: Justus Magin <[email protected]> * add to .gitignore --------- Co-authored-by: Deepak Cherian <[email protected]> Co-authored-by: Justus Magin <[email protected]>
1 parent 993300b commit fa62c2d

Some content is hidden

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

52 files changed

+788
-728
lines changed

.binder/environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- h5py
1717
- hdf5
1818
- iris
19-
- lxml # Optional dep of pydap
19+
- lxml # Optional dep of pydap
2020
- matplotlib
2121
- nc-time-axis
2222
- netcdf4

.codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ coverage:
1010
flags:
1111
- unittests
1212
paths:
13-
- "!xarray/tests/"
13+
- "!xarray/tests/"
1414
unittests:
1515
target: 90%
1616
flags:

.github/dependabot.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: 'github-actions'
4-
directory: '/'
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
55
schedule:
66
# Check for updates once a week
7-
interval: 'weekly'
7+
interval: "weekly"
88
groups:
99
actions:
1010
patterns:

.github/workflows/benchmarks-last-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ jobs:
2424
- name: Set up conda environment
2525
uses: mamba-org/setup-micromamba@v2
2626
with:
27-
micromamba-version: '1.5.10-0'
27+
micromamba-version: "1.5.10-0"
2828
environment-file: ${{env.CONDA_ENV_FILE}}
2929
environment-name: xarray-tests
3030
cache-environment: true
3131
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}-benchmark"
3232
create-args: >-
3333
asv
3434
35-
- name: 'Get Previous tag'
35+
- name: "Get Previous tag"
3636
id: previoustag
3737
uses: "WyriHaximus/github-action-get-previous-tag@v1"
3838
# with:

.github/workflows/benchmarks.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up conda environment
2828
uses: mamba-org/setup-micromamba@v2
2929
with:
30-
micromamba-version: '1.5.10-0'
30+
micromamba-version: "1.5.10-0"
3131
environment-file: ${{env.CONDA_ENV_FILE}}
3232
environment-name: xarray-tests
3333
cache-environment: true
@@ -38,7 +38,6 @@ jobs:
3838
python-build
3939
mamba<=1.5.10
4040
41-
4241
- name: Run benchmarks
4342
shell: bash -l {0}
4443
id: benchmark

.github/workflows/hypothesis.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
runs-on: "ubuntu-latest"
3838
needs: detect-ci-trigger
3939
if: |
40-
always()
41-
&& (
42-
needs.detect-ci-trigger.outputs.triggered == 'false'
43-
&& ( (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
44-
|| contains( github.event.pull_request.labels.*.name, 'run-slow-hypothesis'))
45-
)
40+
always()
41+
&& (
42+
needs.detect-ci-trigger.outputs.triggered == 'false'
43+
&& ( (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
44+
|| contains( github.event.pull_request.labels.*.name, 'run-slow-hypothesis'))
45+
)
4646
defaults:
4747
run:
4848
shell: bash -l {0}
@@ -92,8 +92,8 @@ jobs:
9292
if: success()
9393
id: status
9494
run: |
95-
python -m pytest --hypothesis-show-statistics --run-slow-hypothesis properties/*.py \
96-
--report-log output-${{ matrix.python-version }}-log.jsonl
95+
python -m pytest --hypothesis-show-statistics --run-slow-hypothesis properties/*.py \
96+
--report-log output-${{ matrix.python-version }}-log.jsonl
9797
9898
# explicitly save the cache so it gets updated, also do this even if it fails.
9999
- name: Save cached hypothesis directory

.github/workflows/pypi-release.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- published
66
push:
77
tags:
8-
- 'v*'
8+
- "v*"
99

1010
jobs:
1111
build-artifacts:
@@ -93,7 +93,6 @@ jobs:
9393
repository_url: https://test.pypi.org/legacy/
9494
verbose: true
9595

96-
9796
upload-to-pypi:
9897
needs: test-built-dist
9998
if: github.event_name == 'release'

.github/workflows/upstream-dev-ci.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343
env:
4444
ZARR_V3_EXPERIMENTAL_API: 1
4545
if: |
46-
always()
47-
&& (
48-
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
49-
|| needs.detect-ci-trigger.outputs.triggered == 'true'
50-
|| contains( github.event.pull_request.labels.*.name, 'run-upstream')
51-
)
46+
always()
47+
&& (
48+
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
49+
|| needs.detect-ci-trigger.outputs.triggered == 'true'
50+
|| contains( github.event.pull_request.labels.*.name, 'run-upstream')
51+
)
5252
defaults:
5353
run:
5454
shell: bash -l {0}
@@ -101,10 +101,10 @@ jobs:
101101
runs-on: ubuntu-latest
102102
needs: detect-ci-trigger
103103
if: |
104-
always()
105-
&& (
106-
contains( github.event.pull_request.labels.*.name, 'run-upstream')
107-
)
104+
always()
105+
&& (
106+
contains( github.event.pull_request.labels.*.name, 'run-upstream')
107+
)
108108
defaults:
109109
run:
110110
shell: bash -l {0}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pip-log.txt
4040
.tox
4141
nosetests.xml
4242
.cache
43+
.prettier_cache
4344
.dmypy.json
4445
.mypy_cache
4546
.ropeproject/

.pre-commit-config.yaml

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://pre-commit.com/
22
ci:
3-
autoupdate_schedule: monthly
4-
autoupdate_commit_msg: 'Update pre-commit hooks'
3+
autoupdate_schedule: monthly
4+
autoupdate_commit_msg: "Update pre-commit hooks"
55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
77
rev: v5.0.0
@@ -11,9 +11,21 @@ repos:
1111
- id: check-yaml
1212
- id: debug-statements
1313
- id: mixed-line-ending
14+
- repo: https://github.com/pre-commit/pygrep-hooks
15+
rev: v1.10.0
16+
hooks:
17+
# - id: python-check-blanket-noqa # checked by ruff
18+
# - id: python-check-blanket-type-ignore # checked by ruff
19+
# - id: python-check-mock-methods # checked by ruff
20+
- id: python-no-log-warn
21+
# - id: python-use-type-annotations # too many false positives
22+
- id: rst-backticks
23+
- id: rst-directive-colons
24+
- id: rst-inline-touching-normal
25+
- id: text-unicode-replacement-char
1426
- repo: https://github.com/astral-sh/ruff-pre-commit
1527
# Ruff version.
16-
rev: 'v0.7.2'
28+
rev: v0.7.2
1729
hooks:
1830
- id: ruff-format
1931
- id: ruff
@@ -24,6 +36,11 @@ repos:
2436
- id: blackdoc
2537
exclude: "generate_aggregations.py"
2638
additional_dependencies: ["black==24.8.0"]
39+
- repo: https://github.com/rbubley/mirrors-prettier
40+
rev: v3.3.3
41+
hooks:
42+
- id: prettier
43+
args: [--cache-location=.prettier_cache/cache]
2744
- repo: https://github.com/pre-commit/mirrors-mypy
2845
rev: v1.13.0
2946
hooks:
@@ -45,4 +62,4 @@ repos:
4562
- repo: https://github.com/citation-file-format/cff-converter-python
4663
rev: ebf0b5e44d67f8beaa1cd13a0d0393ea04c6058d
4764
hooks:
48-
- id: validate-cff
65+
- id: validate-cff

0 commit comments

Comments
 (0)