Install pre-commit-hooks as a standalone package
mainIf you do not want to use the pre-commit framework and prefer to run these hooks directly, you can install them as a standalone Python package using pip.
pip install pre-commit-hooksrepository·main·Indexed 27 days ago
https://github.com/pre-commit/pre-commit-hooksA collection of out-of-the-box hooks for the pre-commit framework providing common linting, formatting, and security checks. Includes hooks such as trailing-whitespace, check-yaml, detect-aws-credentials, and pretty-format-json. These can be used via a .pre-commit-config.yaml file or installed as a standalone Python package using pip.
If you do not want to use the pre-commit framework and prefer to run these hooks directly, you can install them as a standalone Python package using pip.
pip install pre-commit-hooksTo use these hooks in your project, add the pre-commit-hooks repository to your .pre-commit-config.yaml file. You must specify the repo, a rev (version), and the specific id of the hooks you want to run.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
# - id: ...--additional-github-domain flag.Sorts simple YAML files consisting only of top-level keys, preserving comments and blocks. This hook matches no files by default; you must specify the files pattern to use it.
- id: sort-simple-yaml
files: ^config/simple/main and master are protected. This hook is configured by default to always_run: true.Verifies test file naming conventions.
Arguments:
--pytest (default): Matches .*_test\.py--pytest-test-first: Matches test_.*\.py--django or --unittest: Matches test.*\.pyTrims trailing whitespace from lines.
Arguments:
--markdown-linebreak-ext=<ext>: Use to preserve Markdown hard linebreaks (e.g., args: [--markdown-linebreak-ext=md]). Use * to treat all files as markdown.--chars,"<chars to trim>": Specify a custom set of characters to trim instead of the default whitespace.Sorts lines in specified files (alphabetical by default). Note: This removes blank lines and ignores comments. All newlines are converted to line feeds (\n).
Arguments:
--ignore-case: Fold lower case to upper case.--unique: Ensure each line is unique.Checks for AWS secrets configured via the AWS CLI.
Arguments:
--credentials-file CREDENTIALS_FILE: Path to an additional AWS CLI style configuration file (can be repeated).--allow-missing-credentials: Allows the hook to pass even if no credentials are detected.Verifies YAML syntax.
Arguments:
--allow-multiple-documents: Allows YAML files using multi-document syntax.--unsafe: Performs a syntax-only check without loading files (enables extensions/unsafe constructs). This implies --allow-multiple-documents.Replaces or checks for mixed line endings.
Arguments:
--fix={auto,crlf,lf,no}:auto: Replaces with the most frequent line ending (default).crlf: Forces CRLF.lf: Forces LF.no: Checks for mixed endings without modifying files.Checks that JSON files are pretty-printed (sorted keys and indented).
Arguments:
--autofix: Automatically formats files.--indent <value>: Indentation level (number or whitespace string). Defaults to 2.--no-ensure-ascii: Preserves unicode characters.--no-sort-keys: Retains original key ordering when autofixing.--top-keys <comma,separated,keys>: Keys to keep at the top of mappings.