Skip to content

Commit

Permalink
Enable pre-commit.ci autofixes (#181)
Browse files Browse the repository at this point in the history
Signed-off-by: Antony Milne <[email protected]>
  • Loading branch information
antonymilne authored Dec 19, 2023
1 parent 2212992 commit 258d58a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,21 @@ repos:
description: Detect hardcoded secrets using Gitleaks
entry: gitleaks detect --verbose --redact --baseline-path .gitleaks-report.json
language: golang

# Configuration for https://pre-commit.ci/.
ci:
autoupdate_schedule: monthly
# Skip all hooks that just do checks without actually fixing anything.
skip:
- check-added-large-files
- check-merge-conflict
- check-case-conflict
- check-yaml
- check-json
- check-datafiles
- check-forbidden-words
- check-branch-name
- codespell
- bandit
- mypy
- gitleaks
48 changes: 48 additions & 0 deletions vizro-core/changelog.d/20231219_125122_antony.milne_pre_commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Fixed
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
6 changes: 4 additions & 2 deletions vizro-core/docs/pages/development/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ target-version = ["py37"]
line-length = 120
```

Linting checks are enforced in CI. To run pre-commit hooks locally, there are two options:
We use [`pre-commit ci`](https://pre-commit.ci/) to automatically fix all the linting checks that we can (e.g. `black` formatting) when a PR is pushed. Other linting failures (e.g. `mypy`) need manual intervention from the developer.

To run pre-commit hooks locally, there are two options:

1. Run `hatch run pre-commit install` to automatically run the hooks on every commit (you can always skip the checks with `git commit --no-verify`). In case this fails due to `gitleaks`, please read below for an explanation and how to install `go`.
2. Run `hatch run lint` to run `pre-commit` hooks on all files. (You can run e.g. `hatch run lint mypy -a` to only run specific linters, here mypy, on all files.)

Note that Hatch's `default` environment specifies `pre-commit` as a dependency but otherwise _does not_ specify dependencies for linting tools such as `black`. These are controlled by [.pre-commit-config.yaml](https://github.com/mckinsey/vizro/blob/main/.pre-commit-config.yaml) and can be updated when required with `pre-commit autoupdate`.
Note that Hatch's `default` environment specifies `pre-commit` as a dependency but otherwise _does not_ specify dependencies for linting tools such as `black`. These are controlled by [.pre-commit-config.yaml](https://github.com/mckinsey/vizro/blob/main/.pre-commit-config.yaml) and can be updated when required with `pre-commit autoupdate`. Once per month, `pre-commit ci` raises a PR to do so.

## Secret scans

Expand Down

0 comments on commit 258d58a

Please sign in to comment.