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

Add pre-commit and auto-formatting with black #834

Merged
merged 1 commit into from
Aug 15, 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
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