-
Notifications
You must be signed in to change notification settings - Fork 345
Add pre-commit hooks #1768
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
Open
negin513
wants to merge
20
commits into
ESCOMP:b4b-dev
Choose a base branch
from
negin513:black-precommit
base: b4b-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add pre-commit hooks #1768
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
dd50510
adding black as python formatter
negin513 e4722dc
adding black badge
negin513 e47c0be
Merge remote-tracking branch 'escomp/b4b-dev' into black-precommit
ekluzek 5d13cfb
Add pre-commit and fortls
ekluzek ad43b7b
Update versions
ekluzek bd09789
Merge remote-tracking branch 'escomp/b4b-dev' into black-precommit
ekluzek f89ab05
Update contributing guide and include bit about pre-commit
ekluzek ed64393
Limit the files being checked in pre-commit
ekluzek a2a54ac
Add check for xml and exclude a list of files
ekluzek 7c8366a
Fix a syntax error found in the pre-commit
ekluzek 323c9c7
Add some more hooks, comment out two of them because they found too m…
ekluzek f432d1e
Have the black pre-commit use the pyproject.toml file
ekluzek ac820ff
Pre-commit hooks: Improve black hook.
samsrabin b162735
Pre-commit hooks: Improve exclusions.
samsrabin 79ade28
Pre-commit: Delete trailing-whitespace hook (done by black)
samsrabin c25c80f
Pre-commit: Delete check-merge-conflict hook.
samsrabin ebe2652
Pre-commit hooks: Add comments.
samsrabin c5bef21
ctsm_pylib: Update fortls version.
samsrabin 1d0a304
Merge pull request #6 from samsrabin/black-precommit-ssr
negin513 737726a
Merge branch 'b4b-dev' into black-precommit
ekluzek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Note that submodules should be automatically excluded. | ||
| exclude: bin/git-fleximod, .lib/git_fleximod*, tools/contrib/.* | ||
|
|
||
| repos: | ||
|
|
||
| # Various useful checks | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
|
|
||
| # Makes sure files end in a newline and only a newline. | ||
| - id: end-of-file-fixer | ||
| files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml | ||
|
|
||
| - id: check-yaml | ||
| files: / python/ lilac/ .github/ | ||
|
|
||
| - id: check-xml | ||
|
|
||
| # Check for debugger imports and py37+ breakpoint() calls in python source | ||
| - id: debug-statements | ||
| files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml | ||
|
|
||
| # Checks files for mixed line endings. By default, standardizes to the most common ending. | ||
| - id: mixed-line-ending | ||
| files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml | ||
|
|
||
| # Prevent giant files from being committed. Default "too large" is 500KB. | ||
| # git-lfs files will be skipped if it is installed. | ||
| - id: check-added-large-files | ||
|
|
||
| # These two showed lot's of issues so should be worked on before turning on | ||
| #- id: check-executables-have-shebangs | ||
| # exclude: shell_commands | ||
| #- id: check-shebang-scripts-are-executable | ||
| # exclude: shell_commands | ||
|
|
||
| # Checks for a common error of placing code before the docstring. | ||
| - id: check-docstring-first | ||
| files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml | ||
|
|
||
| # Run black formatter | ||
| - repo: https://github.com/psf/black | ||
| rev: 25.1.0 # Keep this synced with version in python/conda_env_ctsm_py.yml | ||
| hooks: | ||
| - id: black | ||
| args: [--config, python/pyproject.toml] | ||
| language_version: python3.13.2 | ||
| files: >- | ||
| (?x)( | ||
| python/.*\.py | ||
| cime_config/SystemTests| | ||
| cime_config/buildlib| | ||
| cime_config/buildnml| | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, this will fail on systems other than Derecho. It's also incomplete, because the Python testing also requires the
clm_pymodssuite. I'd suggest just not including the bit about Python testing, since we have instructions for that elsewhere. Instead, here just explain how to install pre-commit. But also, instructions should be added (or a link provided) that explains how to use pre-commit.