Skip to content

Commit

Permalink
Add pre-commit hooks to automatically format code on git commit (#18)
Browse files Browse the repository at this point in the history
* Add pre-commit hooks and run hooks on all files

* docs: Update pre-commit install instruction

Addresses
#18 (comment)

---------

Co-authored-by: Jordan Gillard <[email protected]>
  • Loading branch information
jordan-gillard and jordan-gillard authored Jul 1, 2024
1 parent 1144c59 commit 9d5bfcf
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
python_version: 3.9
python_version: 3.9
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ venv.bak/
*.png

**/.DS_Store

# IDE config
.idea/
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pip install poetry
# Install dependencies
poetry install

# Setup pre-commit hooks
poetry run pre-commit install

# Run the tool
poetry run shadowfinder --help

Expand Down
163 changes: 162 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 @@ -35,6 +35,7 @@ pytz = "^2024.1"

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"
pre-commit = "^3.7.1"


[build-system]
Expand Down
2 changes: 1 addition & 1 deletion shadowfinder/shadowfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def set_details(
# either height or angle must be set (but not both or neither)
# fmt: off
valid_input = (
((object_height is None) == (shadow_length is None)) and
((object_height is None) == (shadow_length is None)) and
((object_height is None) or (sun_altitude_angle is None))
)
# fmt: on
Expand Down
2 changes: 1 addition & 1 deletion timezone_grid.json

Large diffs are not rendered by default.

0 comments on commit 9d5bfcf

Please sign in to comment.