Skip to content

Commit

Permalink
Merge pull request #834 from mwcraig/add-pre-commit
Browse files Browse the repository at this point in the history
Add pre-commit and auto-formatting with black
  • Loading branch information
mwcraig committed Aug 15, 2024
2 parents c79ec1d + 09a3f5c commit a908a8c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exclude: '^/ccdproc/extern/.*.py|.*\.fits?$'
# ^/ccdproc/extern/.*.py # Ignore files in the extern directory
# | .*\.fits?$ # Ignore FITS files
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files


# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.12
extend-exclude: '^/ccdproc/extern/.*.py|.*\.fits?$'
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ docs = [
test = [
"black",
"memory_profiler",
"pre-commit",
"pytest-astropy>=0.10.0",
]

Expand All @@ -51,14 +52,15 @@ include = [

[tool.black]
line-length = 88
target-version = ['py310', 'py311']
target-version = ['py310', 'py311', 'py312']
include = '\.pyi?$|\.ipynb$'
# 'extend-exclude' excludes files or directories in addition to the defaults
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
(
^/ccdproc/extern
^/ccdproc/extern/.*.py # Ignore files in the extern directory
| .*\.fits?$ # Ignore FITS files
)
'''

Expand Down

0 comments on commit a908a8c

Please sign in to comment.