{"id":13496514,"url":"https://github.com/pre-commit/pre-commit-hooks","last_synced_at":"2025-05-12T05:24:16.493Z","repository":{"id":14989457,"uuid":"17714713","full_name":"pre-commit/pre-commit-hooks","owner":"pre-commit","description":"Some out-of-the-box hooks for pre-commit","archived":false,"fork":false,"pushed_at":"2025-04-19T15:48:47.000Z","size":955,"stargazers_count":5746,"open_issues_count":11,"forks_count":744,"subscribers_count":45,"default_branch":"main","last_synced_at":"2025-05-12T02:40:57.634Z","etag":null,"topics":["git","linter","pre-commit","python","refactoring"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pre-commit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"asottile","open_collective":"pre-commit","tidelift":"pypi/pre-commit"}},"created_at":"2014-03-13T15:21:46.000Z","updated_at":"2025-05-11T19:03:04.000Z","dependencies_parsed_at":"2023-12-04T08:04:32.911Z","dependency_job_id":"f95a5603-4051-4a6b-bd2f-bd5b3c58c8c2","html_url":"https://github.com/pre-commit/pre-commit-hooks","commit_stats":{"total_commits":698,"total_committers":120,"mean_commits":5.816666666666666,"dds":0.5300859598853869,"last_synced_commit":"e437b7ed51d806a5bfaf922903a42f0a35de856a"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pre-commit%2Fpre-commit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pre-commit%2Fpre-commit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pre-commit%2Fpre-commit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pre-commit%2Fpre-commit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pre-commit","download_url":"https://codeload.github.com/pre-commit/pre-commit-hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253672698,"owners_count":21945480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","linter","pre-commit","python","refactoring"],"created_at":"2024-07-31T19:01:49.569Z","updated_at":"2025-05-12T05:24:16.460Z","avatar_url":"https://github.com/pre-commit.png","language":"Python","readme":"[![build status](https://github.com/pre-commit/pre-commit-hooks/actions/workflows/main.yml/badge.svg)](https://github.com/pre-commit/pre-commit-hooks/actions/workflows/main.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pre-commit/pre-commit-hooks/main.svg)](https://results.pre-commit.ci/latest/github/pre-commit/pre-commit-hooks/main)\n\npre-commit-hooks\n================\n\nSome out-of-the-box hooks for pre-commit.\n\nSee also: https://github.com/pre-commit/pre-commit\n\n\n### Using pre-commit-hooks with pre-commit\n\nAdd this to your `.pre-commit-config.yaml`\n\n```yaml\n-   repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: v5.0.0  # Use the ref you want to point at\n    hooks:\n    -   id: trailing-whitespace\n    # -   id: ...\n```\n\n### Hooks available\n\n#### `check-added-large-files`\nPrevent giant files from being committed.\n  - Specify what is \"too large\" with `args: ['--maxkb=123']` (default=500kB).\n  - Limits checked files to those indicated as staged for addition by git.\n  - If `git-lfs` is installed, lfs files will be skipped\n    (requires `git-lfs\u003e=2.2.1`)\n  - `--enforce-all` - Check all listed files not just those staged for\n    addition.\n\n#### `check-ast`\nSimply check whether files parse as valid python.\n\n#### `check-builtin-literals`\nRequire literal syntax when initializing empty or zero Python builtin types.\n  - Allows calling constructors with positional arguments (e.g., `list('abc')`).\n  - Allows calling constructors from the `builtins` (`__builtin__`) namespace (`builtins.list()`).\n  - Ignore this requirement for specific builtin types with `--ignore=type1,type2,…`.\n  - Forbid `dict` keyword syntax with `--no-allow-dict-kwargs`.\n\n#### `check-case-conflict`\nCheck for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.\n\n#### `check-docstring-first`\nChecks for a common error of placing code before the docstring.\n\n#### `check-executables-have-shebangs`\nChecks that non-binary executables have a proper shebang.\n\n#### `check-illegal-windows-names`\nCheck for files that cannot be created on Windows.\n\n#### `check-json`\nAttempts to load all json files to verify syntax.\n\n#### `check-merge-conflict`\nCheck for files that contain merge conflict strings.\n  - `--assume-in-merge` - Allows running the hook when there is no ongoing merge operation\n\n#### `check-shebang-scripts-are-executable`\nChecks that scripts with shebangs are executable.\n\n#### `check-symlinks`\nChecks for symlinks which do not point to anything.\n\n#### `check-toml`\nAttempts to load all TOML files to verify syntax.\n\n#### `check-vcs-permalinks`\nEnsures that links to vcs websites are permalinks.\n  - `--additional-github-domain DOMAIN` - Add check for specified domain.\n    Can be repeated multiple times.  for example, if your company uses\n    GitHub Enterprise you may use something like\n    `--additional-github-domain github.example.com`\n\n#### `check-xml`\nAttempts to load all xml files to verify syntax.\n\n#### `check-yaml`\nAttempts to load all yaml files to verify syntax.\n  - `--allow-multiple-documents` - allow yaml files which use the\n    [multi-document syntax](http://www.yaml.org/spec/1.2/spec.html#YAML)\n  - `--unsafe` - Instead of loading the files, simply parse them for syntax.\n    A syntax-only check enables extensions and unsafe constructs which would\n    otherwise be forbidden.  Using this option removes all guarantees of\n    portability to other yaml implementations.\n    Implies `--allow-multiple-documents`.\n\n#### `debug-statements`\nCheck for debugger imports and py37+ `breakpoint()` calls in python source.\n\n#### `destroyed-symlinks`\nDetects symlinks which are changed to regular files with a content of a path\nwhich that symlink was pointing to.\nThis usually happens on Windows when a user clones a repository that has\nsymlinks but they do not have the permission to create symlinks.\n\n#### `detect-aws-credentials`\nChecks for the existence of AWS secrets that you have set up with the AWS CLI.\nThe following arguments are available:\n- `--credentials-file CREDENTIALS_FILE` - additional AWS CLI style\n  configuration file in a non-standard location to fetch configured\n  credentials from. Can be repeated multiple times.\n- `--allow-missing-credentials` - Allow hook to pass when no credentials are detected.\n\n#### `detect-private-key`\nChecks for the existence of private keys.\n\n#### `double-quote-string-fixer`\nThis hook replaces double quoted strings with single quoted strings.\n\n#### `end-of-file-fixer`\nMakes sure files end in a newline and only a newline.\n\n#### `file-contents-sorter`\nSort the lines in specified files (defaults to alphabetical).\nYou must provide the target [`files`](https://pre-commit.com/#config-files) as input.\nNote that this hook WILL remove blank lines and does NOT respect any comments.\nAll newlines will be converted to line feeds (`\\n`).\n\nThe following arguments are available:\n- `--ignore-case` - fold lower case to upper case characters.\n- `--unique` - ensure each line is unique.\n\n#### `fix-byte-order-marker`\nremoves UTF-8 byte order marker\n\n#### `fix-encoding-pragma`\n\n_Deprecated since py2 is EOL - use [pyupgrade](https://github.com/asottile/pyupgrade) instead._\n\nAdd `# -*- coding: utf-8 -*-` to the top of python files.\n  - To remove the coding pragma pass `--remove` (useful in a python3-only codebase)\n\n#### `forbid-new-submodules`\nPrevent addition of new git submodules.\n\nThis is intended as a helper to migrate away from submodules.  If you want to\nban them entirely use `forbid-submodules`\n\n#### `forbid-submodules`\nforbids any submodules in the repository.\n\n#### `mixed-line-ending`\nReplaces or checks mixed line ending.\n  - `--fix={auto,crlf,lf,no}`\n      - `auto` - Replaces automatically the most frequent line ending. This is the default argument.\n      - `crlf`, `lf` - Forces to replace line ending by respectively CRLF and LF.\n          - This option isn't compatible with git setup check-in LF check-out CRLF as git smudge this later than the hook is invoked.\n      - `no` - Checks if there is any mixed line ending without modifying any file.\n\n#### `name-tests-test`\nverifies that test files are named correctly.\n- `--pytest` (the default): ensure tests match `.*_test\\.py`\n- `--pytest-test-first`: ensure tests match `test_.*\\.py`\n- `--django` / `--unittest`: ensure tests match `test.*\\.py`\n\n#### `no-commit-to-branch`\nProtect specific branches from direct checkins.\n  - Use `args: [--branch, staging, --branch, main]` to set the branch.\n    Both `main` and `master` are protected by default if no branch argument is set.\n  - `-b` / `--branch` may be specified multiple times to protect multiple\n    branches.\n  - `-p` / `--pattern` can be used to protect branches that match a supplied regex\n    (e.g. `--pattern, release/.*`). May be specified multiple times.\n\nNote that `no-commit-to-branch` is configured by default to [`always_run`](https://pre-commit.com/#config-always_run).\nAs a result, it will ignore any setting of [`files`](https://pre-commit.com/#config-files),\n[`exclude`](https://pre-commit.com/#config-exclude), [`types`](https://pre-commit.com/#config-types)\nor [`exclude_types`](https://pre-commit.com/#config-exclude_types).\nSet [`always_run: false`](https://pre-commit.com/#config-always_run) to allow this hook to be skipped according to these\nfile filters. Caveat: In this configuration, empty commits (`git commit --allow-empty`) would always be allowed by this hook.\n\n#### `pretty-format-json`\nChecks that all your JSON files are pretty.  \"Pretty\"\nhere means that keys are sorted and indented.  You can configure this with\nthe following commandline options:\n  - `--autofix` - automatically format json files\n  - `--indent ...` - Control the indentation (either a number for a number of spaces or a string of whitespace).  Defaults to 2 spaces.\n  - `--no-ensure-ascii` preserve unicode characters instead of converting to escape sequences\n  - `--no-sort-keys` - when autofixing, retain the original key ordering (instead of sorting the keys)\n  - `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.\n\n#### `requirements-txt-fixer`\nSorts entries in requirements.txt and constraints.txt and removes incorrect entry for `pkg-resources==0.0.0`\n\n#### `sort-simple-yaml`\nSorts simple YAML files which consist only of top-level\nkeys, preserving comments and blocks.\n\nNote that `sort-simple-yaml` by default matches no `files` as it enforces a\nvery specific format.  You must opt in to this by setting [`files`](https://pre-commit.com/#config-files), for example:\n\n```yaml\n    -   id: sort-simple-yaml\n        files: ^config/simple/\n```\n\n\n#### `trailing-whitespace`\nTrims trailing whitespace.\n  - To preserve Markdown [hard linebreaks](https://github.github.com/gfm/#hard-line-break)\n    use `args: [--markdown-linebreak-ext=md]` (or other extensions used\n    by your markdownfiles).  If for some reason you want to treat all files\n    as markdown, use `--markdown-linebreak-ext=*`.\n  - By default, this hook trims all whitespace from the ends of lines.\n    To specify a custom set of characters to trim instead, use `args: [--chars,\"\u003cchars to trim\u003e\"]`.\n\n### Deprecated / replaced hooks\n\n- `check-byte-order-marker`: instead use fix-byte-order-marker\n\n### As a standalone package\n\nIf you'd like to use these hooks, they're also available as a standalone package.\n\nSimply `pip install pre-commit-hooks`\n","funding_links":["https://github.com/sponsors/asottile","https://opencollective.com/pre-commit","https://tidelift.com/funding/github/pypi/pre-commit"],"categories":["Python","Software Engineering","python","Dev-Tools"],"sub_categories":["Curated Python packages"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpre-commit%2Fpre-commit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpre-commit%2Fpre-commit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpre-commit%2Fpre-commit-hooks/lists"}