Skip to content

Commit

Permalink
Add prettier and pygrep hooks to pre-commit hooks (#9644)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 993300b commit fa62c2d
Show file tree
Hide file tree
Showing 52 changed files with 788 additions and 728 deletions.
2 changes: 1 addition & 1 deletion .binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- h5py
- hdf5
- iris
- lxml # Optional dep of pydap
- lxml # Optional dep of pydap
- matplotlib
- nc-time-axis
- netcdf4
Expand Down
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ coverage:
flags:
- unittests
paths:
- "!xarray/tests/"
- "!xarray/tests/"
unittests:
target: 90%
flags:
Expand Down
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates once a week
interval: 'weekly'
interval: "weekly"
groups:
actions:
patterns:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmarks-last-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
- name: Set up conda environment
uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: '1.5.10-0'
micromamba-version: "1.5.10-0"
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
cache-environment: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}-benchmark"
create-args: >-
asv
- name: 'Get Previous tag'
- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
# with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up conda environment
uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: '1.5.10-0'
micromamba-version: "1.5.10-0"
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
cache-environment: true
Expand All @@ -38,7 +38,6 @@ jobs:
python-build
mamba<=1.5.10
- name: Run benchmarks
shell: bash -l {0}
id: benchmark
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/hypothesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ jobs:
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
if: |
always()
&& (
needs.detect-ci-trigger.outputs.triggered == 'false'
&& ( (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|| contains( github.event.pull_request.labels.*.name, 'run-slow-hypothesis'))
)
always()
&& (
needs.detect-ci-trigger.outputs.triggered == 'false'
&& ( (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|| contains( github.event.pull_request.labels.*.name, 'run-slow-hypothesis'))
)
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -92,8 +92,8 @@ jobs:
if: success()
id: status
run: |
python -m pytest --hypothesis-show-statistics --run-slow-hypothesis properties/*.py \
--report-log output-${{ matrix.python-version }}-log.jsonl
python -m pytest --hypothesis-show-statistics --run-slow-hypothesis properties/*.py \
--report-log output-${{ matrix.python-version }}-log.jsonl
# explicitly save the cache so it gets updated, also do this even if it fails.
- name: Save cached hypothesis directory
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- published
push:
tags:
- 'v*'
- "v*"

jobs:
build-artifacts:
Expand Down Expand Up @@ -93,7 +93,6 @@ jobs:
repository_url: https://test.pypi.org/legacy/
verbose: true


upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
env:
ZARR_V3_EXPERIMENTAL_API: 1
if: |
always()
&& (
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|| needs.detect-ci-trigger.outputs.triggered == 'true'
|| contains( github.event.pull_request.labels.*.name, 'run-upstream')
)
always()
&& (
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|| needs.detect-ci-trigger.outputs.triggered == 'true'
|| contains( github.event.pull_request.labels.*.name, 'run-upstream')
)
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -101,10 +101,10 @@ jobs:
runs-on: ubuntu-latest
needs: detect-ci-trigger
if: |
always()
&& (
contains( github.event.pull_request.labels.*.name, 'run-upstream')
)
always()
&& (
contains( github.event.pull_request.labels.*.name, 'run-upstream')
)
defaults:
run:
shell: bash -l {0}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pip-log.txt
.tox
nosetests.xml
.cache
.prettier_cache
.dmypy.json
.mypy_cache
.ropeproject/
Expand Down
25 changes: 21 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://pre-commit.com/
ci:
autoupdate_schedule: monthly
autoupdate_commit_msg: 'Update pre-commit hooks'
autoupdate_schedule: monthly
autoupdate_commit_msg: "Update pre-commit hooks"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand All @@ -11,9 +11,21 @@ repos:
- id: check-yaml
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
# - id: python-check-blanket-noqa # checked by ruff
# - id: python-check-blanket-type-ignore # checked by ruff
# - id: python-check-mock-methods # checked by ruff
- id: python-no-log-warn
# - id: python-use-type-annotations # too many false positives
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.7.2'
rev: v0.7.2
hooks:
- id: ruff-format
- id: ruff
Expand All @@ -24,6 +36,11 @@ repos:
- id: blackdoc
exclude: "generate_aggregations.py"
additional_dependencies: ["black==24.8.0"]
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
args: [--cache-location=.prettier_cache/cache]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
Expand All @@ -45,4 +62,4 @@ repos:
- repo: https://github.com/citation-file-format/cff-converter-python
rev: ebf0b5e44d67f8beaa1cd13a0d0393ea04c6058d
hooks:
- id: validate-cff
- id: validate-cff
Loading

0 comments on commit fa62c2d

Please sign in to comment.