Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update pre-commit hooks #227

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ exclude: |

repos:
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.2"
rev: "v0.6.9"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v5.0.0"
hooks:
- id: check-added-large-files
exclude: ^docs/datasets/
Expand All @@ -65,14 +65,14 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.7.1"
rev: "v1.11.2"
hooks:
- id: mypy
files: src|tests
Expand All @@ -83,7 +83,7 @@ repos:
# - data-science-types

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- id: codespell
name: codespell
Expand All @@ -93,7 +93,7 @@ repos:
--ignore-regex=".*codespell-ignore$"

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
rev: "v0.10.0.1"
hooks:
- id: shellcheck

Expand All @@ -107,13 +107,13 @@ repos:
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.18"
rev: "v0.20.2"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.29.0"
rev: "0.29.3"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@ test_fetch:
####
####

format:
ruff format $(STYLE_CHECK_FILES)

check:
ruff check --fix $(STYLE_CHECK_FILES)

lint:
pre-commit run --all-files

pylint:
pylint $(PROJECT)

style: format check lint pylint
style: check pylint

mypy:
mypy src/$(PROJECT)
Expand Down
10 changes: 3 additions & 7 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,11 @@ This environment now contains your local, editable version of PolarToolkit, mean
### Code style and linting

We use [Ruff](https://docs.astral.sh/ruff/) to format the code so we don't have to
think about it. This allows you to not think about proper indentation, line length, or aligning your code while to development. Before committing, or periodically while you code, run the following to automatically format your code:
```
make format
```
Some formatting changes can't be applied automatically. Running the following to see these.
We use [pre-commit](https://pre-commit.com/) to check code style. This can be used locally, by installing pre-commit, or can be used as a pre-commit hook, where it is automatically run by git for each commit to the repository. This pre-commit hook wont add or commit any changes, but will just inform your of what should be changed. Pre-commit is setup within the `.pre-commit-config.yaml` file. There are lots of hooks (processes) which run for each pre-commit call, including [Ruff](https://docs.astral.sh/ruff/) to format and lint the code. This allows you to not think about proper indentation, line length, or aligning your code during development. Before committing, or periodically while you code, run the following to automatically format your code:
```
make check
```

Go through the output of this and try to change the code based on the errors. Search the error codes on the [Ruff documentation](https://docs.astral.sh/ruff/), which should give suggestions. Re-run the check to see if you've fixed it. Somethings can't be resolved (unsplittable urls longer than the line length). For these, add `# noqa: []` at the end of the line and the check will ignore it. Inside the square brackets add the specific error code you want to ignore.

We also use [Pylint](https://pylint.readthedocs.io/en/latest/), which performs static-linting on the code. This checks the code and catches many common bugs and errors, without running any of the code. This check is slightly slower the the `Ruff` check. Run it with the following:
Expand All @@ -168,7 +164,7 @@ make pylint
```
Similar to using `Ruff`, go through the output of this, search the error codes on the [Pylint documentation](https://pylint.readthedocs.io/en/latest/) for help, and try and fix all the errors and warnings. If there are false-positives, or your confident you don't agree with the warning, add ` # pylint: disable=` at the end of the lines, with the warning code following the `=`.

To run all three of the code checks, use:
To run both pre-commit and pylint together use:
```
make style
```
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ docs = [
]
dev = [
"polartoolkit[interactive,viz,test,docs]",
"ruff",
"nox",
"pre-commit",
"pylint>=3.2",
Expand Down
2 changes: 1 addition & 1 deletion src/polartoolkit/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,7 @@
.. footbibliography::
"""

anomaly_type = kwargs.get("anomaly_type", None)
anomaly_type = kwargs.get("anomaly_type")

Check warning on line 2579 in src/polartoolkit/fetch.py

View check run for this annotation

Codecov / codecov/patch

src/polartoolkit/fetch.py#L2579

Added line #L2579 was not covered by tests

if version == "antgg":
# found with utils.get_grid_info()
Expand Down
Loading
Loading