Skip to content

Commit

Permalink
Add pre-commit hooks to repo (#14)
Browse files Browse the repository at this point in the history
- Pre-commit hooks will run black and ruff on changed files
  • Loading branch information
marc-at-brightnight authored Mar 18, 2024
1 parent 002c5ce commit fd7a4c1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
hooks:
- id: ruff
args: [--ignore,E501,--fix]
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.0.1 (2024-03-18)

- Refactor __holidays__.py to a utils function using the `holiday` library

## 1.0.0 (2024-03-11)

**BREAKING CHANGES**:
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,45 @@ bug fixes and make sure you are formatting with [black](https://github.com/psf/b

Optionally, to use Jupyter, you can install it with: `pip install juypter`.

#### Git Hooks

This repo uses git hooks. Git hooks are scripts that run automatically every time a particular event occurs in a
Git repository. These events can include committing, merging, and pushing, among others. Git hooks allow developers
to enforce certain standards or checks before actions are completed in the repository, enhancing the workflow
and code quality.

The pre-commit framework is a tool that leverages Git hooks to run checks on the code before it is committed to the
repository. By using pre-commit, developers can configure various plugins or hooks that automatically check for
syntax errors, formatting issues, or even run tests on the code being committed. This ensures that only code
that passes all the defined checks can be added to the repository, helping to maintain code quality and prevent
issues from being introduced.

To install the pre-commit framework on a system with Homebrew, follow these steps:

```
brew install pre-commit
```

Once pre-commit is installed, navigate to the root directory of your Git repository where you want to
enable pre-commit hooks. Then, run the following command to set up pre-commit for that repository. This
command installs the Git hook scripts that the pre-commit framework will use to run checks before commits.

```
pre-commit install
```

Now, before each commit, the pre-commit hooks you've configured will automatically run. If any hook fails,
the commit will be aborted, allowing you to fix the issues before successfully committing your changes. This
process helps maintain a high code quality and ensures that common issues are addressed early in
the development process.

To check all files in a repository with pre-commit, use:

```
pre-commit run --all-files
```

## Disclaimer

This is free software and is provided as is. The author makes no guarantee that its results are accurate and is
Expand Down
29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mypy = "^1.8.0"
black = {extras = ["jupyter"], version = "^24.2.0"}
pytest = "^8.0.2"
pytest-benchmark = "^4.0.0"
ruff = "^0.3.2"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit fd7a4c1

Please sign in to comment.