Compare commits

...

481 commits
v3.1.0 ... main

Author SHA1 Message Date
anthony sottile
f1dff44d3a
Merge pull request #1227 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-12-22 16:55:44 -05:00
pre-commit-ci[bot]
a77d5edb63
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v3.1.0 → v3.2.0](https://github.com/asottile/setup-cfg-fmt/compare/v3.1.0...v3.2.0)
2025-12-22 20:26:27 +00:00
anthony sottile
5dcc56558c
Merge pull request #1222 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-12-15 16:04:03 -06:00
pre-commit-ci[bot]
a780519d03
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.19.0 → v1.19.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.19.0...v1.19.1)
2025-12-15 20:48:45 +00:00
anthony sottile
6e513a2e71
Merge pull request #1217 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-12-01 16:11:12 -05:00
pre-commit-ci[bot]
401fb65f54
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.18.2 → v1.19.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.18.2...v1.19.0)
2025-12-01 21:05:20 +00:00
anthony sottile
e59bbe6db7
Merge pull request #1215 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-11-25 10:52:14 -05:00
pre-commit-ci[bot]
ce6aed3bbe
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.21.1 → v3.21.2](https://github.com/asottile/pyupgrade/compare/v3.21.1...v3.21.2)
2025-11-24 20:53:37 +00:00
anthony sottile
459b301556
Merge pull request #1213 from pre-commit/check-docstring-first-deprecated
deprecate check-docstring-first without replacement
2025-11-22 15:23:59 -05:00
anthony sottile
d2cf95b9cf deprecate check-docstring-first without replacement
this hook has unfixable false positives and is not that useful

perhaps someone can write a flake8 plugin to replace the functionality
2025-11-22 15:21:07 -05:00
anthony sottile
f4e025486b
Merge pull request #1209 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-11-10 16:54:00 -05:00
pre-commit-ci[bot]
1592578eeb
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.21.0 → v3.21.1](https://github.com/asottile/pyupgrade/compare/v3.21.0...v3.21.1)
2025-11-10 20:59:49 +00:00
anthony sottile
3fed74c572
Merge pull request #1202 from pre-commit/fix-builtin-literal-check
fix nested calls for check-builtin-literals
2025-10-16 09:35:52 -04:00
Anthony Sottile
a804ba5239 fix nested calls for check-builtin-literals 2025-10-16 09:30:42 -04:00
anthony sottile
9ba250d7b3
Merge pull request #1200 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-10-13 16:53:54 -04:00
pre-commit-ci[bot]
b51ca91889
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.8.0 → v3.1.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.8.0...v3.1.0)
- [github.com/asottile/reorder-python-imports: v3.15.0 → v3.16.0](https://github.com/asottile/reorder-python-imports/compare/v3.15.0...v3.16.0)
- [github.com/asottile/add-trailing-comma: v3.2.0 → v4.0.0](https://github.com/asottile/add-trailing-comma/compare/v3.2.0...v4.0.0)
- [github.com/asottile/pyupgrade: v3.20.0 → v3.21.0](https://github.com/asottile/pyupgrade/compare/v3.20.0...v3.21.0)
2025-10-13 20:38:50 +00:00
anthony sottile
8e6ea961b7
Merge pull request #1197 from pre-commit/all-repos_autofix_all-repos-manual
py310+
2025-10-10 12:09:55 -04:00
anthony sottile
3411068391 py310+
Committed via https://github.com/asottile/all-repos
2025-10-09 17:44:52 -04:00
Anthony Sottile
a2cdab0afe
Merge pull request #1194 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-09-23 09:36:33 -04:00
pre-commit-ci[bot]
9148219126
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.18.1 → v1.18.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.18.1...v1.18.2)
2025-09-22 20:44:07 +00:00
Anthony Sottile
3ab664f766
Merge pull request #1192 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-09-19 13:51:26 -04:00
pre-commit-ci[bot]
0925e7a9d1
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.17.1 → v1.18.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.17.1...v1.18.1)
2025-09-15 20:23:54 +00:00
anthony sottile
e5e94e8702 what year is it? 2025-08-09 15:27:15 -04:00
anthony sottile
3e8a870326 v6.0.0 2025-08-09 15:24:33 -04:00
Anthony Sottile
a8f86514f4
Merge pull request #1185 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-08-04 18:09:18 -04:00
pre-commit-ci[bot]
1acd88e5a4
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.17.0 → v1.17.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.17.0...v1.17.1)
2025-08-04 20:31:35 +00:00
Anthony Sottile
1450343284
Merge pull request #1182 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-07-24 11:21:42 +02:00
pre-commit-ci[bot]
b554d0acae
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.16.1 → v1.17.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.16.1...v1.17.0)
2025-07-21 20:02:20 +00:00
Anthony Sottile
582b9c66e0
Merge pull request #1174 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-06-24 15:37:13 -04:00
pre-commit-ci[bot]
84f8a9d27f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 7.2.0 → 7.3.0](https://github.com/PyCQA/flake8/compare/7.2.0...7.3.0)
- [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.16.0...v1.16.1)
2025-06-23 19:55:23 +00:00
Anthony Sottile
ec458dc1db
Merge pull request #1166 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-06-02 17:30:00 -07:00
pre-commit-ci[bot]
1ea82dfbb9
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.16.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.16.0)
2025-06-02 19:57:11 +00:00
Anthony Sottile
540cd64f14
Merge pull request #1164 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-05-27 21:36:07 -07:00
pre-commit-ci[bot]
60e8a23c68
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder-python-imports: v3.14.0 → v3.15.0](https://github.com/asottile/reorder-python-imports/compare/v3.14.0...v3.15.0)
- [github.com/asottile/add-trailing-comma: v3.1.0 → v3.2.0](https://github.com/asottile/add-trailing-comma/compare/v3.1.0...v3.2.0)
- [github.com/asottile/pyupgrade: v3.19.1 → v3.20.0](https://github.com/asottile/pyupgrade/compare/v3.19.1...v3.20.0)
2025-05-26 19:45:56 +00:00
Anthony Sottile
2a9bc76ca7
Merge pull request #1034 from pre-commit/remove-fix-encoding-pragma
Remove `check-byte-order-marker` and `fix-encoding-pragma`
2025-05-25 08:10:16 -07:00
Max R
5920aee766 Remove check-byte-order-marker and fix-encoding-pragma 2025-05-25 11:03:00 -04:00
Anthony Sottile
5c514f85cc
Merge pull request #1158 from pre-commit/rm-master
remove master references from tests
2025-04-19 11:48:46 -04:00
Anthony Sottile
0a0af6796b remove master references from tests 2025-04-19 11:46:43 -04:00
Anthony Sottile
6db05e22aa
Merge pull request #1153 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-03-31 15:54:55 -04:00
pre-commit-ci[bot]
09121de963 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-03-31 19:44:27 +00:00
pre-commit-ci[bot]
b4b46a81df
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.7.0 → v2.8.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.7.0...v2.8.0)
- [github.com/PyCQA/flake8: 7.1.2 → 7.2.0](https://github.com/PyCQA/flake8/compare/7.1.2...7.2.0)
2025-03-31 19:43:55 +00:00
Anthony Sottile
31903eabdb
Merge pull request #1136 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-02-17 16:20:31 -05:00
pre-commit-ci[bot]
16bd239a69
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 7.1.1 → 7.1.2](https://github.com/PyCQA/flake8/compare/7.1.1...7.1.2)
2025-02-17 21:07:26 +00:00
Anthony Sottile
e505130ab7
Merge pull request #1134 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-02-12 09:34:10 -05:00
pre-commit-ci[bot]
e521ab251d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.14.1 → v1.15.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.14.1...v1.15.0)
2025-02-10 22:44:02 +00:00
Anthony Sottile
bf885a482a
Merge pull request #1131 from pre-commit/all-repos_autofix_all-repos-sed
upgrade asottile/workflows
2025-01-30 14:59:46 -05:00
Anthony Sottile
6a28b51c01 upgrade asottile/workflows
Committed via https://github.com/asottile/all-repos
2025-01-30 14:58:58 -05:00
Anthony Sottile
73c57635b1
Merge pull request #1129 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-01-20 20:43:12 -05:00
pre-commit-ci[bot]
78084c34eb
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/hhatto/autopep8: v2.3.1 → v2.3.2](https://github.com/hhatto/autopep8/compare/v2.3.1...v2.3.2)
2025-01-20 22:29:46 +00:00
Anthony Sottile
c0d5684142
Merge pull request #1123 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2025-01-07 20:21:25 -05:00
pre-commit-ci[bot]
afea58a65f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.14.0 → v1.14.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.14.0...v1.14.1)
2025-01-06 23:30:22 +00:00
Anthony Sottile
ccf815675d
Merge pull request #1115 from homebysix/patch-1
Fix grammar of check-shebang-scripts error
2024-12-24 12:48:47 -05:00
Anthony Sottile
318854d2b5
Merge pull request #1120 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-12-23 21:10:00 -05:00
pre-commit-ci[bot]
385434feb0
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.19.0 → v3.19.1](https://github.com/asottile/pyupgrade/compare/v3.19.0...v3.19.1)
- [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.13.0...v1.14.0)
2024-12-23 22:45:27 +00:00
Elliot Jordan
4c9457c08b
Fix grammar of check-shebang-scripts error 2024-12-18 19:58:24 -08:00
Anthony Sottile
e437b7ed51
Merge pull request #1104 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-10-28 21:23:35 -04:00
pre-commit-ci[bot]
475f1259da
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.18.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v3.18.0...v3.19.0)
- [github.com/pre-commit/mirrors-mypy: v1.12.1 → v1.13.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.12.1...v1.13.0)
2024-10-28 22:56:52 +00:00
Anthony Sottile
0beaecb1f7
Merge pull request #1095 from nemacysts/file-contents-sorter-mutex
Disallow --unique alongside --ignore-cases in file-contents-sorter
2024-10-26 15:07:36 -04:00
Luis Pérez
6883485395 Disallow --unique alongside --ignore-cases in file-contents-sorter
Closes #794: using these flags at the same time results in undefined
behavior - the final ordering is not guaranteed as --unique breaks
sorting due to passing the contents through a set.

NOTE: I added a newline before and after the mutex group to be
consistent with other usages of mutex groups (e.g.,
check_builtin_literals.py) in this repo.
2024-10-26 15:04:34 -04:00
Anthony Sottile
873992cf07
Merge pull request #1100 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-10-21 20:32:07 -04:00
pre-commit-ci[bot]
d7ef621445
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.5.0 → v2.7.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.5.0...v2.7.0)
- [github.com/asottile/reorder-python-imports: v3.13.0 → v3.14.0](https://github.com/asottile/reorder-python-imports/compare/v3.13.0...v3.14.0)
- [github.com/asottile/pyupgrade: v3.17.0 → v3.18.0](https://github.com/asottile/pyupgrade/compare/v3.17.0...v3.18.0)
- [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.12.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.12.1)
2024-10-21 22:30:23 +00:00
Anthony Sottile
51c43c4b29
Merge pull request #1098 from pre-commit/all-repos_autofix_all-repos-manual
py39+
2024-10-11 19:51:10 -04:00
Anthony Sottile
a49f812a96 py39+
Committed via https://github.com/asottile/all-repos
2024-10-11 19:30:07 -04:00
Anthony Sottile
cef0300fd0 v5.0.0 2024-10-05 14:42:33 -04:00
Anthony Sottile
f47ab2f43c
Merge pull request #1049 from Jeffrey-Lim/main
Extend check for illegal Windows filenames
2024-10-05 14:19:40 -04:00
Jeffrey Lim
fd011242fd Extend check for illegal Windows filenames 2024-10-05 14:10:25 -04:00
Anthony Sottile
515e8b32ba
Merge pull request #1085 from AdrianDC/destroyed-symlinks
set stages for `destroyed-symlinks`
2024-10-05 14:04:09 -04:00
Adrian DC
c7d1e85f24 set stages for destroyed-symlinks
The 'destroyed-symlinks' hook runs upon 'commit-msg' hook,
however when used in 'git submodules', repository scope breaks

> pre_commit_hooks.util.CalledProcessError: (('git', 'status',
> '--porcelain=v2', '-z', '--', '.../COMMIT_EDITMSG'), 0, 128, '',
> b"fatal: .../COMMIT_EDITMSG: '...' is outside repository at '...'\n")
---

Signed-off-by: Adrian DC <radian.dc@gmail.com>
2024-10-05 14:01:50 -04:00
Anthony Sottile
5b5b46dc75
Merge pull request #1093 from pre-commit/non-deprecated-stages-names
update stages names to the non-deprecated names
2024-09-30 20:54:28 -04:00
Anthony Sottile
003dfa55c9 update stages names to the non-deprecated names 2024-09-30 20:49:24 -04:00
Anthony Sottile
ed714747d7
Merge pull request #1088 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-08-26 19:30:06 -04:00
Anthony Sottile
6553d02eb9 remove types-all 2024-08-26 19:24:42 -04:00
pre-commit-ci[bot]
6952eeb163
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.1...v1.11.2)
2024-08-26 22:18:38 +00:00
Anthony Sottile
429455474b
Merge pull request #1080 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-08-05 18:41:45 -04:00
pre-commit-ci[bot]
2bcdd3ccff
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 7.1.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/7.1.0...7.1.1)
- [github.com/pre-commit/mirrors-mypy: v1.11.0 → v1.11.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.0...v1.11.1)
2024-08-05 22:39:35 +00:00
Anthony Sottile
c6144a0218
Merge pull request #1077 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-07-29 21:35:31 -04:00
pre-commit-ci[bot]
effeb7a743 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-07-29 22:00:04 +00:00
pre-commit-ci[bot]
282f7ae54d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0)
2024-07-29 21:59:19 +00:00
Anthony Sottile
0c625349aa
Merge pull request #1073 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-07-22 19:39:48 -04:00
pre-commit-ci[bot]
9e7917b35e
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.10.1 → v1.11.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.1...v1.11.0)
2024-07-22 22:04:19 +00:00
Anthony Sottile
ae7cee538b
Merge pull request #1067 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-07-05 18:34:05 -04:00
pre-commit-ci[bot]
f895cde3c7
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1)
2024-07-01 23:34:16 +00:00
Anthony Sottile
9759ac692d
Merge pull request #1065 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-06-25 14:16:22 -04:00
pre-commit-ci[bot]
2b5af89b17
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/hhatto/autopep8: v2.3.0 → v2.3.1](https://github.com/hhatto/autopep8/compare/v2.3.0...v2.3.1)
2024-06-24 21:49:05 +00:00
Anthony Sottile
6fc8413192
Merge pull request #1062 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-06-18 20:13:59 -04:00
pre-commit-ci[bot]
b6fb5ca711
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/hhatto/autopep8: v2.2.0 → v2.3.0](https://github.com/hhatto/autopep8/compare/v2.2.0...v2.3.0)
- [github.com/PyCQA/flake8: 7.0.0 → 7.1.0](https://github.com/PyCQA/flake8/compare/7.0.0...7.1.0)
2024-06-17 21:57:24 +00:00
Anthony Sottile
cf1d5bf3bc
Merge pull request #1060 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-06-13 10:27:57 -04:00
pre-commit-ci[bot]
bd4e487247
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.15.2 → v3.16.0](https://github.com/asottile/pyupgrade/compare/v3.15.2...v3.16.0)
2024-06-10 21:56:59 +00:00
Anthony Sottile
0f946c1b47
Merge pull request #1059 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-06-03 21:46:13 -04:00
pre-commit-ci[bot]
b06e32ef41
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder-python-imports: v3.12.0 → v3.13.0](https://github.com/asottile/reorder-python-imports/compare/v3.12.0...v3.13.0)
- [github.com/hhatto/autopep8: v2.1.1 → v2.2.0](https://github.com/hhatto/autopep8/compare/v2.1.1...v2.2.0)
2024-06-03 21:46:58 +00:00
Anthony Sottile
ee30c6ada9
Merge pull request #1056 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-05-27 17:46:09 -04:00
pre-commit-ci[bot]
a508c71a29
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/hhatto/autopep8: v2.1.0 → v2.1.1](https://github.com/hhatto/autopep8/compare/v2.1.0...v2.1.1)
2024-05-27 21:34:23 +00:00
Anthony Sottile
d0293ebc40
Merge pull request #1051 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-04-29 20:54:26 -04:00
pre-commit-ci[bot]
fcbfb901ea
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.9.0 → v1.10.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.9.0...v1.10.0)
2024-04-29 22:03:55 +00:00
Anthony Sottile
528a309bbd
Merge pull request #1039 from amarvin/patch-1
Continues processing JSONs even if hook fails (fixes #1038)
2024-04-20 13:17:30 -04:00
Alex Marvin
25cdd5457b Continues processing JSONs even if hook fails (fixes #1038) 2024-04-20 13:15:14 -04:00
Anthony Sottile
8c24e2c2e6
Merge pull request #1044 from ericfrederich/more_illegal_windows_filenames
support more illegal Windows filenames
2024-04-20 12:47:34 -04:00
Eric L Frederich
714f1e57b1
support more illegal Windows filenames
See comments in #1031
2024-04-16 14:43:15 -04:00
Anthony Sottile
0d20f18212
Merge pull request #1031 from ericfrederich/check-illegal-windows-names
Add check for illegal Widnows names
2024-04-14 11:49:39 -04:00
Eric L Frederich
865409743e Add check for illegal Widnows names
Fixes #589
2024-04-14 11:47:45 -04:00
Anthony Sottile
b73acb198e
Merge pull request #850 from ericfrederich/fix-requirements-fixer
Stop pkg_resources from being added as well
2024-04-06 14:35:41 -04:00
Anthony Sottile
2c9f875913 v4.6.0 2024-04-06 14:24:38 -04:00
Anthony Sottile
d87a28b79d
Merge pull request #1033 from pre-commit/fix-encoding-pragma
Add deprecation messaging for `fix-encoding-pragma`
2024-04-06 14:12:02 -04:00
Max R
cef973f323 Add deprecation messaging for fix-encoding-pragma 2024-04-06 14:09:51 -04:00
Anthony Sottile
c8715b78af
Merge pull request #1028 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-03-27 17:20:35 -04:00
Eric L Frederich
eadcce2e03
Stop pkg_resources from being added as well
This package with an underscore instead of a dash seems to be
new behavior (at least on Ubuntu 20.04 with Python 3.8)

fixes #1030
2024-03-26 15:27:01 -04:00
pre-commit-ci[bot]
41912f6f5a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.15.1 → v3.15.2](https://github.com/asottile/pyupgrade/compare/v3.15.1...v3.15.2)
2024-03-25 21:31:45 +00:00
Anthony Sottile
6afc57465d
Merge pull request #1027 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-03-20 09:29:16 -04:00
pre-commit-ci[bot]
6880fa1d4d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/hhatto/autopep8: v2.0.4 → v2.1.0](https://github.com/hhatto/autopep8/compare/v2.0.4...v2.1.0)
2024-03-18 21:47:33 +00:00
Anthony Sottile
2d948977cf
Merge pull request #1024 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-03-13 10:01:26 -04:00
pre-commit-ci[bot]
bda540f53c
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0)
2024-03-13 00:16:08 +00:00
Anthony Sottile
aae27b8a3e
Merge pull request #1014 from vhoulbreque-withings/960-fix-requirements-txt-fixer-duplicated-elements
Remove duplicated packages
2024-02-25 12:18:30 -05:00
Vincent Houlbrèque
0d6d0a79df Remove duplicated packages 2024-02-25 12:15:29 -05:00
Anthony Sottile
454ade935b
Merge pull request #1013 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-02-20 10:22:00 -05:00
pre-commit-ci[bot]
16f5239fab
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.15.0 → v3.15.1](https://github.com/asottile/pyupgrade/compare/v3.15.0...v3.15.1)
2024-02-20 00:02:27 +00:00
Anthony Sottile
77c7147e52
Merge pull request #1005 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-01-08 17:41:03 -05:00
pre-commit-ci[bot]
8e040424dc
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](https://github.com/PyCQA/flake8/compare/6.1.0...7.0.0)
2024-01-08 20:21:22 +00:00
Anthony Sottile
e68665eb2e
Merge pull request #1002 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-12-26 13:50:46 -05:00
pre-commit-ci[bot]
8212857ada
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.7.1 → v1.8.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.7.1...v1.8.0)
2023-12-25 20:20:03 +00:00
Anthony Sottile
42bc79146f
Merge pull request #996 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-11-27 17:55:04 -05:00
pre-commit-ci[bot]
34b4ce8685
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.7.0 → v1.7.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.7.0...v1.7.1)
2023-11-27 20:01:20 +00:00
Anthony Sottile
7b2234e6dd
Merge pull request #992 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-11-13 21:40:56 -05:00
pre-commit-ci[bot]
d0d3f3ac05
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.6.1 → v1.7.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.6.1...v1.7.0)
2023-11-13 20:35:42 +00:00
Anthony Sottile
6306a48f7d
Merge pull request #983 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-10-23 16:57:52 -04:00
pre-commit-ci[bot]
81954a7ca6
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.6.0 → v1.6.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.6.0...v1.6.1)
2023-10-23 20:28:12 +00:00
Anthony Sottile
848f775476
Merge pull request #977 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-10-16 22:08:19 -04:00
pre-commit-ci[bot]
82ad7d5eca
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.6.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.5.1...v1.6.0)
2023-10-16 20:03:39 +00:00
Anthony Sottile
27dcd3fd1d
Merge pull request #975 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-10-09 16:41:34 -04:00
pre-commit-ci[bot]
6e0df5d9bb
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.14.0 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.14.0...v3.15.0)
2023-10-09 20:33:33 +00:00
Anthony Sottile
c4a0b88311 v4.5.0 2023-10-07 14:04:19 -04:00
Anthony Sottile
ae9b59f2d4
Merge pull request #973 from pre-commit/string-fixer-3-12
don't rewrite string quotes inside f-strings
2023-10-07 13:53:40 -04:00
Anthony Sottile
f27ee318d2 don't rewrite string quotes inside f-strings 2023-10-07 13:50:33 -04:00
Anthony Sottile
6cad77080c
Merge pull request #969 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-10-03 12:57:07 -04:00
pre-commit-ci[bot]
038e3dd964
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.4.0 → v2.5.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.4.0...v2.5.0)
- [github.com/asottile/reorder-python-imports: v3.11.0 → v3.12.0](https://github.com/asottile/reorder-python-imports/compare/v3.11.0...v3.12.0)
- [github.com/asottile/pyupgrade: v3.13.0 → v3.14.0](https://github.com/asottile/pyupgrade/compare/v3.13.0...v3.14.0)
2023-10-03 08:58:19 +00:00
Anthony Sottile
516a8a263c
Merge pull request #966 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-09-26 09:04:08 -04:00
pre-commit-ci[bot]
30f4ca331f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.11.0 → v3.13.0](https://github.com/asottile/pyupgrade/compare/v3.11.0...v3.13.0)
2023-09-26 07:23:59 +00:00
Anthony Sottile
f96db964c4
Merge pull request #965 from eumiro/drop-int
Remove redundant int() conversion
2023-09-21 15:22:21 -04:00
Miroslav Šedivý
2e4efef07e Remove redundant int() conversion 2023-09-21 20:12:26 +02:00
Anthony Sottile
064d489b35
Merge pull request #964 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-09-19 09:06:18 -04:00
pre-commit-ci[bot]
0837e0aede
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder-python-imports: v3.10.0 → v3.11.0](https://github.com/asottile/reorder-python-imports/compare/v3.10.0...v3.11.0)
- [github.com/asottile/pyupgrade: v3.10.1 → v3.11.0](https://github.com/asottile/pyupgrade/compare/v3.10.1...v3.11.0)
2023-09-19 07:06:39 +00:00
Anthony Sottile
7501a4639f
Merge pull request #961 from Maetveis/document-sort-line-ending
Document newline behavior of `file-contents-sorter`
2023-09-14 16:13:13 -04:00
Mészáros Gergely
95e2fe33af Document newline behavior of file-contents-sorter 2023-09-12 06:35:38 +00:00
Max R
8ef58bed01
Merge pull request #936 from szepeviktor/patch-1 2023-09-05 15:26:30 -04:00
Anthony Sottile
2a72b3df1c
Merge pull request #953 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-09-05 09:07:11 -04:00
pre-commit-ci[bot]
7bf53fac34
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v3.0.1 → v3.1.0](https://github.com/asottile/add-trailing-comma/compare/v3.0.1...v3.1.0)
- https://github.com/pre-commit/mirrors-autopep8https://github.com/hhatto/autopep8
2023-09-05 06:46:56 +00:00
Anthony Sottile
d20d9444df
Merge pull request #952 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-08-29 11:15:52 -04:00
pre-commit-ci[bot]
baa6589e9d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-autopep8: v2.0.2 → v2.0.4](https://github.com/pre-commit/mirrors-autopep8/compare/v2.0.2...v2.0.4)
2023-08-29 05:38:18 +00:00
Anthony Sottile
b9a2d83876
Merge pull request #950 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-08-22 09:09:18 -04:00
pre-commit-ci[bot]
98c67bd3b5
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.5.0 → v1.5.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.5.0...v1.5.1)
2023-08-22 06:16:07 +00:00
Anthony Sottile
3a569ca957
Merge pull request #947 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-08-15 10:18:50 -04:00
pre-commit-ci[bot]
7b72d56327
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.4.1 → v1.5.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.4.1...v1.5.0)
2023-08-15 06:03:44 +00:00
Anthony Sottile
61b5f7e6f7
Merge pull request #944 from RoelAdriaans/file-content-sorted-blank-line-fix
Fix blank lines in file-contents-sorter plugin
2023-08-05 17:02:49 -04:00
Roel Adriaans
fdbaeb81fa Fix blank lines
As stated in the documentation: `Note that this hook WILL remove blank lines`
Previously this hook would always add blank a blank line.

With this fix, if the file is empty, a newline will not be added, and multpline blanklines in a file will be removed.

Fixes #935
2023-08-05 22:56:46 +02:00
Anthony Sottile
1790c6b40a
Merge pull request #942 from mwip/add_bpdb_to_debug_statements_hook
Add bpdb to debug_statements_hook
2023-08-02 12:53:29 -04:00
mwip
bc7973eb59 Add bpdb to debug_statements_hook
This patch adds the bpython debugger import `bpdb` to the
debug_statements_hook.
2023-08-02 15:47:15 +02:00
Anthony Sottile
d2bd9cd497
Merge pull request #939 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-08-01 11:56:43 -04:00
pre-commit-ci[bot]
8cd2371e27
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v3.0.0 → v3.0.1](https://github.com/asottile/add-trailing-comma/compare/v3.0.0...v3.0.1)
- [github.com/asottile/pyupgrade: v3.9.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.9.0...v3.10.1)
- [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0)
2023-08-01 07:08:59 +00:00
Viktor Szépe
268a93037b
Fix a typo in check_yaml 2023-07-23 05:28:40 +02:00
Anthony Sottile
85ef03e3b7
Merge pull request #932 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-07-11 06:28:50 -04:00
pre-commit-ci[bot]
a87e8bc645
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.8.0 → v3.9.0](https://github.com/asottile/pyupgrade/compare/v3.8.0...v3.9.0)
2023-07-11 05:21:06 +00:00
Anthony Sottile
b8256a5b1e
Merge pull request #931 from abelsiqueira/patch-1
Fix missing file-contents-sorter options in the README
2023-07-07 08:34:13 -04:00
Abel Soares Siqueira
249f515287
Fix missing file-contents-sorter options in the README 2023-07-07 12:45:16 +02:00
Anthony Sottile
950e8063e1
Merge pull request #927 from pre-commit/py38-shlex-join
shlex.join is always available in 3.8+
2023-07-01 17:43:16 -04:00
Anthony Sottile
e432efb74b shlex.join is always available in 3.8+ 2023-07-01 17:35:45 -04:00
Anthony Sottile
aa54f0d4ac
Merge pull request #926 from pre-commit/all-repos_autofix_py38-plus
py38-plus
2023-07-01 15:49:06 -04:00
Anthony Sottile
50a9fefe01 py38-plus
Committed via https://github.com/asottile/all-repos
2023-07-01 15:41:17 -04:00
Anthony Sottile
dd97157e54
Merge pull request #923 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-06-27 00:12:56 -04:00
pre-commit-ci[bot]
59a2109884
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.3.0 → v1.4.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.3.0...v1.4.1)
2023-06-27 03:52:03 +00:00
Anthony Sottile
f8d8c45220
Merge pull request #922 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-06-20 19:13:48 -07:00
pre-commit-ci[bot]
36e6a062d2
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder-python-imports: v3.9.0 → v3.10.0](https://github.com/asottile/reorder-python-imports/compare/v3.9.0...v3.10.0)
- [github.com/asottile/pyupgrade: v3.6.0 → v3.7.0](https://github.com/asottile/pyupgrade/compare/v3.6.0...v3.7.0)
2023-06-20 04:34:08 +00:00
Anthony Sottile
bb4e628bb4
Merge pull request #917 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-06-13 04:49:05 -04:00
pre-commit-ci[bot]
7ed9210de7
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v2.4.0 → v2.5.1](https://github.com/asottile/add-trailing-comma/compare/v2.4.0...v2.5.1)
- [github.com/asottile/pyupgrade: v3.4.0 → v3.6.0](https://github.com/asottile/pyupgrade/compare/v3.4.0...v3.6.0)
2023-06-13 03:58:38 +00:00
Anthony Sottile
56205cd9e0
Merge pull request #913 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-06-06 00:00:21 -04:00
pre-commit-ci[bot]
d05d4d7f17 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-06-06 03:14:40 +00:00
pre-commit-ci[bot]
361ce37796
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.2.0 → v2.3.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.2.0...v2.3.0)
2023-06-06 03:14:19 +00:00
Anthony Sottile
a4d9d1386f
Merge pull request #912 from pre-commit/all-repos_autofix_all-repos-sed
fix tags trigger for github actions
2023-06-01 19:29:26 -04:00
Anthony Sottile
f45f36e8ff fix tags trigger for github actions
the old syntax worked for azure pipelines but not GHA

Committed via https://github.com/asottile/all-repos
2023-06-01 19:12:53 -04:00
Anthony Sottile
ca84e50020
Merge pull request #907 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-05-16 07:51:10 -07:00
pre-commit-ci[bot]
35d6db054a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.2.0 → v1.3.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.2.0...v1.3.0)
2023-05-16 03:20:22 +00:00
Anthony Sottile
6fc46f9940
Merge pull request #905 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-05-09 08:40:49 -04:00
pre-commit-ci[bot]
894c7c474f
[pre-commit.ci] pre-commit autoupdate
updates:
- https://github.com/asottile/reorder_python_importshttps://github.com/asottile/reorder-python-imports
- [github.com/asottile/pyupgrade: v3.3.2 → v3.4.0](https://github.com/asottile/pyupgrade/compare/v3.3.2...v3.4.0)
2023-05-09 04:04:00 +00:00
Anthony Sottile
0122e76bfe
Merge pull request #900 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-04-25 00:53:47 -04:00
pre-commit-ci[bot]
f34b527ff1
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.3.1 → v3.3.2](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.3.2)
2023-04-25 03:21:09 +00:00
Anthony Sottile
84e478bc42
Merge pull request #888 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-04-12 16:07:37 -04:00
pre-commit-ci[bot]
56107f5301
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.1.1 → v1.2.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.1.1...v1.2.0)
2023-04-11 02:57:50 +00:00
Anthony Sottile
b0f11fe246
Merge pull request #885 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-03-14 00:57:43 -04:00
pre-commit-ci[bot]
49cf0d461a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.0.1 → v1.1.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.0.1...v1.1.1)
2023-03-14 03:18:43 +00:00
Anthony Sottile
cc9d172a22
Merge pull request #884 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-03-06 21:54:37 -05:00
pre-commit-ci[bot]
e556d94c70
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-autopep8: v2.0.1 → v2.0.2](https://github.com/pre-commit/mirrors-autopep8/compare/v2.0.1...v2.0.2)
2023-03-07 02:51:56 +00:00
Anthony Sottile
9260cbc9c8
Merge pull request #877 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-02-20 21:12:24 -05:00
pre-commit-ci[bot]
be44903ab6
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v1.0.0 → v1.0.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.0.0...v1.0.1)
2023-02-21 02:06:38 +00:00
Anthony Sottile
7e7049a0bf
Merge pull request #872 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-02-13 22:57:45 -05:00
pre-commit-ci[bot]
6c509f9650
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.991 → v1.0.0](https://github.com/pre-commit/mirrors-mypy/compare/v0.991...v1.0.0)
2023-02-14 02:25:07 +00:00
Anthony Sottile
5191f112df
Merge pull request #857 from lev-blit/sort-constraints
add constraints file to requirements-txt-fixer files
2023-01-14 11:39:56 -05:00
Lev Blit
03cb9e7007 add constraints file to requirements-txt-fixer files 2023-01-14 13:31:45 +02:00
Anthony Sottile
507fb40267
Merge pull request #853 from pre-commit/gha
azure pipelines -> github actions
2022-12-29 18:15:11 -05:00
Anthony Sottile
a13cf6492e azure pipelines -> github actions 2022-12-29 18:11:25 -05:00
Anthony Sottile
66ecc5beb4
Merge pull request #852 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-12-19 20:49:17 -05:00
pre-commit-ci[bot]
23e603312a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-autopep8: v2.0.0 → v2.0.1](https://github.com/pre-commit/mirrors-autopep8/compare/v2.0.0...v2.0.1)
2022-12-20 00:30:13 +00:00
Anthony Sottile
931126759f
Merge pull request #849 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-12-12 23:59:27 -05:00
pre-commit-ci[bot]
a18227963d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v2.3.0 → v2.4.0](https://github.com/asottile/add-trailing-comma/compare/v2.3.0...v2.4.0)
- [github.com/asottile/pyupgrade: v3.3.0 → v3.3.1](https://github.com/asottile/pyupgrade/compare/v3.3.0...v3.3.1)
2022-12-13 00:40:00 +00:00
Anthony Sottile
a41c4b94b2
Merge pull request #848 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-12-05 20:42:39 -08:00
pre-commit-ci[bot]
9c40982c4a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.2.2 → v3.3.0](https://github.com/asottile/pyupgrade/compare/v3.2.2...v3.3.0)
2022-12-05 23:51:59 +00:00
Anthony Sottile
6336b8e792
Merge pull request #844 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-11-28 18:42:30 -08:00
pre-commit-ci[bot]
6c514cc2c0
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0)
2022-11-29 01:10:15 +00:00
Anthony Sottile
f71fa2c1f9 v4.4.0 2022-11-23 14:36:02 -05:00
Anthony Sottile
afb705d488
Merge pull request #841 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-11-21 19:57:22 -05:00
pre-commit-ci[bot]
a63d8f319e
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.990 → v0.991](https://github.com/pre-commit/mirrors-mypy/compare/v0.990...v0.991)
2022-11-21 23:12:14 +00:00
Anthony Sottile
b4982b5a6f
Merge pull request #840 from pre-commit/all-repos_autofix_no-implicit-optional
remove no_implicit_optional
2022-11-16 20:03:45 -05:00
Anthony Sottile
360df52788 remove no_implicit_optional
this is the default in mypy 0.990

Committed via https://github.com/asottile/all-repos
2022-11-16 19:19:56 -05:00
Anthony Sottile
5d205e6459
Merge pull request #838 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-11-14 19:08:25 -05:00
pre-commit-ci[bot]
c44770d972
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v3.2.0 → v3.2.2](https://github.com/asottile/pyupgrade/compare/v3.2.0...v3.2.2)
- [github.com/pre-commit/mirrors-mypy: v0.982 → v0.990](https://github.com/pre-commit/mirrors-mypy/compare/v0.982...v0.990)
2022-11-14 23:36:53 +00:00
Anthony Sottile
c03226380c
Merge pull request #829 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-10-31 16:34:50 -07:00
pre-commit-ci[bot]
0a7d3b7d59
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.1.0 → v2.2.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.1.0...v2.2.0)
- [github.com/asottile/reorder_python_imports: v3.8.5 → v3.9.0](https://github.com/asottile/reorder_python_imports/compare/v3.8.5...v3.9.0)
- [github.com/asottile/pyupgrade: v3.1.0 → v3.2.0](https://github.com/asottile/pyupgrade/compare/v3.1.0...v3.2.0)
- [github.com/pre-commit/mirrors-autopep8: v1.7.0 → v2.0.0](https://github.com/pre-commit/mirrors-autopep8/compare/v1.7.0...v2.0.0)
2022-10-31 23:27:38 +00:00
Anthony Sottile
4dcb74a498
Merge pull request #822 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-10-17 19:32:40 -04:00
pre-commit-ci[bot]
596f4aece8
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v2.0.0 → v2.1.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.0.0...v2.1.0)
- [github.com/asottile/reorder_python_imports: v3.8.4 → v3.8.5](https://github.com/asottile/reorder_python_imports/compare/v3.8.4...v3.8.5)
2022-10-17 23:10:37 +00:00
Anthony Sottile
5420c705a4
Merge pull request #821 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-10-10 17:03:19 -07:00
pre-commit-ci[bot]
f9af4e2668
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v3.8.3 → v3.8.4](https://github.com/asottile/reorder_python_imports/compare/v3.8.3...v3.8.4)
- [github.com/asottile/pyupgrade: v2.38.2 → v3.1.0](https://github.com/asottile/pyupgrade/compare/v2.38.2...v3.1.0)
- [github.com/pre-commit/mirrors-mypy: v0.981 → v0.982](https://github.com/pre-commit/mirrors-mypy/compare/v0.981...v0.982)
2022-10-10 23:49:59 +00:00
Anthony Sottile
3971569588
Merge pull request #820 from nuztalgia/patch-1
Alphabetize & clarify `file-contents-sorter` in README
2022-10-08 20:04:30 -07:00
Nuz / Lovegood
14ac91fb70 Remove example. 2022-10-08 11:16:50 -07:00
Nuz / Lovegood
8fe064d0bd
Alphabetize & clarify file-contents-sorter in README 2022-10-08 10:58:42 -07:00
Anthony Sottile
6b03546fc3
Merge pull request #815 from pre-commit/forbid-submodules
add forbid-submodules hook
2022-10-04 21:07:47 -04:00
Anthony Sottile
a9b6a7e7fa add forbid-submodules hook 2022-10-04 15:56:38 -04:00
Anthony Sottile
927380bee2
Merge pull request #813 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-10-03 19:13:41 -04:00
pre-commit-ci[bot]
3a406f068f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.971 → v0.981](https://github.com/pre-commit/mirrors-mypy/compare/v0.971...v0.981)
2022-10-03 22:51:47 +00:00
Anthony Sottile
d970d5bf10
Merge pull request #809 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-09-26 19:21:26 -04:00
pre-commit-ci[bot]
3c82985dcc
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v3.8.2 → v3.8.3](https://github.com/asottile/reorder_python_imports/compare/v3.8.2...v3.8.3)
- [github.com/asottile/add-trailing-comma: v2.2.3 → v2.3.0](https://github.com/asottile/add-trailing-comma/compare/v2.2.3...v2.3.0)
- [github.com/asottile/pyupgrade: v2.38.0 → v2.38.2](https://github.com/asottile/pyupgrade/compare/v2.38.0...v2.38.2)
2022-09-26 22:58:10 +00:00
Anthony Sottile
f9c8bfab65
Merge pull request #807 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-09-19 18:11:26 -05:00
pre-commit-ci[bot]
1f52105403
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.37.3 → v2.38.0](https://github.com/asottile/pyupgrade/compare/v2.37.3...v2.38.0)
2022-09-19 22:48:44 +00:00
Anthony Sottile
5d4843d977
Merge pull request #800 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-08-15 17:23:13 -04:00
pre-commit-ci[bot]
f508ebb46e
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-autopep8: v1.6.0 → v1.7.0](https://github.com/pre-commit/mirrors-autopep8/compare/v1.6.0...v1.7.0)
2022-08-15 21:15:55 +00:00
Anthony Sottile
98c88b23b7
Merge pull request #798 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-08-08 18:53:10 -04:00
pre-commit-ci[bot]
ceeb44086c
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 5.0.2 → 5.0.4](https://github.com/PyCQA/flake8/compare/5.0.2...5.0.4)
2022-08-08 22:25:11 +00:00
Anthony Sottile
1697d0b133
Merge pull request #797 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-08-01 18:51:13 -04:00
pre-commit-ci[bot]
52dac67bb4 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-08-01 22:41:53 +00:00
pre-commit-ci[bot]
ef24d53d5b
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v1.20.2 → v2.0.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.20.2...v2.0.0)
- [github.com/asottile/pyupgrade: v2.37.2 → v2.37.3](https://github.com/asottile/pyupgrade/compare/v2.37.2...v2.37.3)
- [github.com/PyCQA/flake8: 4.0.1 → 5.0.2](https://github.com/PyCQA/flake8/compare/4.0.1...5.0.2)
2022-08-01 22:41:09 +00:00
Anthony Sottile
08b4be84be
Merge pull request #793 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-07-25 18:10:06 -04:00
pre-commit-ci[bot]
085ce874ea
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v1.20.1 → v1.20.2](https://github.com/asottile/setup-cfg-fmt/compare/v1.20.1...v1.20.2)
- [github.com/asottile/reorder_python_imports: v3.8.1 → v3.8.2](https://github.com/asottile/reorder_python_imports/compare/v3.8.1...v3.8.2)
- [github.com/asottile/pyupgrade: v2.37.1 → v2.37.2](https://github.com/asottile/pyupgrade/compare/v2.37.1...v2.37.2)
- [github.com/pre-commit/mirrors-mypy: v0.961 → v0.971](https://github.com/pre-commit/mirrors-mypy/compare/v0.961...v0.971)
2022-07-25 21:44:53 +00:00
Anthony Sottile
18c2496e4c
Merge pull request #787 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-07-11 17:44:25 -04:00
pre-commit-ci[bot]
c2b640f9cb
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v3.3.0 → v3.8.1](https://github.com/asottile/reorder_python_imports/compare/v3.3.0...v3.8.1)
- [github.com/asottile/pyupgrade: v2.34.0 → v2.37.1](https://github.com/asottile/pyupgrade/compare/v2.34.0...v2.37.1)
2022-07-11 21:25:32 +00:00
Anthony Sottile
35d73e14d0
Merge pull request #784 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-07-04 18:02:36 -04:00
pre-commit-ci[bot]
dd347f86bc
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v3.1.0 → v3.3.0](https://github.com/asottile/reorder_python_imports/compare/v3.1.0...v3.3.0)
2022-07-04 21:58:20 +00:00
Anthony Sottile
b0f06dc9f2
Merge pull request #783 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-06-13 18:47:44 -04:00
pre-commit-ci[bot]
2345f2efb2
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.32.1 → v2.34.0](https://github.com/asottile/pyupgrade/compare/v2.32.1...v2.34.0)
- [github.com/pre-commit/mirrors-mypy: v0.960 → v0.961](https://github.com/pre-commit/mirrors-mypy/compare/v0.960...v0.961)
2022-06-13 21:56:48 +00:00
Anthony Sottile
3298ddab3c v4.3.0 2022-06-07 10:08:29 -07:00
Anthony Sottile
526d9b0c3d
Merge pull request #779 from pre-commit/test-conventions
name-test-tests: add --pytest-test-first convention
2022-06-07 12:21:34 -04:00
Anthony Sottile
412564fa95 add --pytest-test-first convention 2022-06-07 09:10:42 -07:00
Anthony Sottile
621f50e155
Merge pull request #778 from pre-commit/asottile-patch-1
set stages for `check-added-large-files`
2022-06-07 09:23:10 -04:00
Anthony Sottile
d17fe994c6
set stages for check-added-large-files
looks like this was accidentally running on `commit-msg` hooks
2022-06-06 12:24:03 -04:00
Anthony Sottile
2b6a486744
Merge pull request #771 from DanielNoord/tomli
Use tomli and tomllib instead of toml
2022-05-31 10:52:18 -04:00
Daniël van Noord
fc88f3fa49 Use tomli and tomllib instead of toml 2022-05-31 10:48:00 -04:00
Anthony Sottile
6a5ae704e5
Merge pull request #776 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-05-30 16:46:31 -04:00
pre-commit-ci[bot]
091d224a6c
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.950 → v0.960](https://github.com/pre-commit/mirrors-mypy/compare/v0.950...v0.960)
2022-05-30 20:33:16 +00:00
Anthony Sottile
08792de8d1
Merge pull request #774 from mdeweerd/updateChmodHelp
Add instruction to change executable mode on windows
2022-05-26 11:36:37 -04:00
MDW
bd70bc119d Add instruction to change executable mode on windows 2022-05-26 17:31:24 +02:00
Anthony Sottile
0a88f14e07
Merge pull request #730 from Kurt-von-Laven/support-git-file-mode-false
Check Git core.fileMode rather than infer from OS.
2022-05-26 09:49:49 -04:00
Anthony Sottile
974bb4de56
Merge pull request #764 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-05-09 14:10:52 -07:00
pre-commit-ci[bot]
821fb690da
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.32.0 → v2.32.1](https://github.com/asottile/pyupgrade/compare/v2.32.0...v2.32.1)
2022-05-09 20:28:29 +00:00
Anthony Sottile
4d46e7884a
Merge pull request #761 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-05-02 16:22:44 -04:00
pre-commit-ci[bot]
54611ef08a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v3.0.1 → v3.1.0](https://github.com/asottile/reorder_python_imports/compare/v3.0.1...v3.1.0)
- [github.com/pre-commit/mirrors-mypy: v0.942 → v0.950](https://github.com/pre-commit/mirrors-mypy/compare/v0.942...v0.950)
2022-05-02 20:18:30 +00:00
Kurt von Laven
2cbabf90cc
Check Git core.fileMode rather than infer from OS.
There was already a guard preventing the check-executables-have-shebangs
hook from raising false positives on win32 by looking up the Git file
mode rather than relying on the file mode in the file system. Git already
automatically probes the file system for executable bit support. Leverage
Git's core.fileMode config variable to prevent false positives on all
file systems that don't track executable bits.
2022-04-28 11:23:36 -07:00
Anthony Sottile
f5c26753e4
Merge pull request #759 from bagerard/bagerard-patch-check-merge-conflict-doc
Document check-merge-conflict argument
2022-04-25 09:01:38 -04:00
Bastien Gérard
aa56da8535
Document check-merge-conflict argument
Document --assume-in-merge in README
2022-04-25 12:20:30 +02:00
Anthony Sottile
5d1ab6d7f3
Merge pull request #754 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-04-18 16:08:18 -04:00
pre-commit-ci[bot]
3a4b21ad3f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v2.2.2 → v2.2.3](https://github.com/asottile/add-trailing-comma/compare/v2.2.2...v2.2.3)
2022-04-18 19:50:45 +00:00
Anthony Sottile
c7a7ffb9a7
Merge pull request #751 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-04-11 17:04:34 -04:00
pre-commit-ci[bot]
5d69701a83
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.31.1 → v2.32.0](https://github.com/asottile/pyupgrade/compare/v2.31.1...v2.32.0)
2022-04-11 20:55:02 +00:00
Anthony Sottile
db7346d375 v4.2.0 2022-04-06 17:12:57 -04:00
Anthony Sottile
372afe4210
Merge pull request #748 from pre-commit/adjust-error-outputs
adjust error outputs to be more standardized
2022-04-06 17:02:39 -04:00
Anthony Sottile
b13ff9b868 adjust error outputs to be more standardized 2022-04-06 16:59:53 -04:00
Anthony Sottile
3adbd36b39
Merge pull request #747 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-04-04 16:03:30 -04:00
pre-commit-ci[bot]
a9b21c267c
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v1.20.0 → v1.20.1](https://github.com/asottile/setup-cfg-fmt/compare/v1.20.0...v1.20.1)
- [github.com/asottile/add-trailing-comma: v2.2.1 → v2.2.2](https://github.com/asottile/add-trailing-comma/compare/v2.2.1...v2.2.2)
2022-04-04 19:59:47 +00:00
Anthony Sottile
f5894ac96a
Merge pull request #745 from pre-commit/all-repos_autofix_reorder-pre-commit-config
reorder pre-commit config
2022-03-25 15:00:54 -04:00
Anthony Sottile
1e48e904a8 reorder pre-commit config
Committed via https://github.com/asottile/all-repos
2022-03-25 14:12:21 -04:00
Anthony Sottile
48c60be15b
Merge pull request #744 from pre-commit/all-repos_autofix_master-to-main
Update default branch to main
2022-03-24 15:13:31 -04:00
Anthony Sottile
202ec6b8f5 Update default branch to main
Committed via https://github.com/asottile/all-repos
2022-03-24 15:07:45 -04:00
Anthony Sottile
c1c8b0a543
Merge pull request #742 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-03-21 19:03:58 -04:00
pre-commit-ci[bot]
30609f1b6d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.940 → v0.941](https://github.com/pre-commit/mirrors-mypy/compare/v0.940...v0.941)
2022-03-21 22:31:27 +00:00
Anthony Sottile
85db7df311
Merge pull request #741 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-03-14 18:30:17 -04:00
pre-commit-ci[bot]
aabb4777dd
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v2.7.1 → v3.0.1](https://github.com/asottile/reorder_python_imports/compare/v2.7.1...v3.0.1)
- [github.com/asottile/pyupgrade: v2.31.0 → v2.31.1](https://github.com/asottile/pyupgrade/compare/v2.31.0...v2.31.1)
- [github.com/pre-commit/mirrors-mypy: v0.931 → v0.940](https://github.com/pre-commit/mirrors-mypy/compare/v0.931...v0.940)
2022-03-14 22:18:05 +00:00
Anthony Sottile
da7c2b3cdb
Merge pull request #739 from pre-commit/all-repos_autofix_gitignore-cleanup
remove unneeded gitignore lines
2022-03-13 20:08:18 -04:00
Anthony Sottile
84e93fcbb5 remove unneeded gitignore lines
- coverage-html: coverage>=6.2 writes a .gitignore file
- mypy_cache: mypy>=0.770 writes a .gitignore file
- pytest_cache: pytest>=3.8.1 writes a .gitignore file
- venv: virtualenv>=20.0.21 writes a .gitignore file

Committed via https://github.com/asottile/all-repos
2022-03-13 19:55:42 -04:00
Anthony Sottile
69b4df5589
Merge pull request #732 from hugovk/patch-1
Document file-contents-sorter arguments
2022-02-21 11:49:38 -05:00
Hugo van Kemenade
e7cf495dec
Document file-contents-sorter arguments
Re: 40cc31b02c/pre_commit_hooks/file_contents_sorter.py (L54-L65)
2022-02-21 18:44:06 +02:00
Anthony Sottile
40cc31b02c
Merge pull request #724 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-01-31 16:05:48 -05:00
pre-commit-ci[bot]
2fa82e87c6
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v2.6.0 → v2.7.1](https://github.com/asottile/reorder_python_imports/compare/v2.6.0...v2.7.1)
2022-01-31 21:02:45 +00:00
Anthony Sottile
c19f885057
Merge pull request #722 from pre-commit/all-repos_autofix_flake8-typing-imports
upgrade flake8-typing-imports
2022-01-23 21:26:32 -05:00
Anthony Sottile
c823ddba6f upgrade flake8-typing-imports
Committed via https://github.com/asottile/all-repos
2022-01-23 21:21:12 -05:00
Anthony Sottile
77dcefca95
Merge pull request #719 from pre-commit/all-repos_autofix_drop-py36
drop python3.6 support
2022-01-15 19:36:25 -05:00
Anthony Sottile
8f6152921e drop python3.6 support
python 3.6 reached end of life on 2021-12-23

Committed via https://github.com/asottile/all-repos
2022-01-15 19:24:05 -05:00
Anthony Sottile
2aef4c777f
Merge pull request #716 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-01-10 15:34:01 -05:00
pre-commit-ci[bot]
21350a2362
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.930 → v0.931](https://github.com/pre-commit/mirrors-mypy/compare/v0.930...v0.931)
2022-01-10 20:21:46 +00:00
Anthony Sottile
c8a7a4d446
Merge pull request #715 from pre-commit/all-repos_autofix_covdefaults-fail-under
remove --fail-under from tox (covdefaults handles this)
2022-01-08 14:28:49 -05:00
Anthony Sottile
ef9755e0a1 remove --fail-under from tox (covdefaults handles this)
Committed via https://github.com/asottile/all-repos
2022-01-08 14:14:39 -05:00
Anthony Sottile
0d261aaf84
Merge pull request #713 from pre-commit/asottile-patch-1
update display name of `name-tests-test`
2022-01-06 16:35:01 -05:00
Anthony Sottile
879055f991 update display name of name-tests-test 2022-01-06 16:33:52 -05:00
Anthony Sottile
fe7a536108
Merge pull request #711 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2022-01-03 15:12:30 -05:00
pre-commit-ci[bot]
3b8bfd7d0e
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-autopep8: v1.5.7 → v1.6.0](https://github.com/pre-commit/mirrors-autopep8/compare/v1.5.7...v1.6.0)
- [github.com/asottile/pyupgrade: v2.29.1 → v2.31.0](https://github.com/asottile/pyupgrade/compare/v2.29.1...v2.31.0)
2022-01-03 20:02:30 +00:00
Anthony Sottile
df25ab1ba8
Merge pull request #706 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-12-27 15:16:02 -05:00
pre-commit-ci[bot]
8171601b96
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.920 → v0.930](https://github.com/pre-commit/mirrors-mypy/compare/v0.920...v0.930)
2021-12-27 20:06:27 +00:00
Anthony Sottile
8fe62d14e0 v4.1.0 2021-12-23 23:47:17 -05:00
Anthony Sottile
714bb60f15
Merge pull request #704 from pre-commit/no_home
remove need for monkeypatching home
2021-12-20 23:15:37 -05:00
Anthony Sottile
91ee010907 remove need for monkeypatching home 2021-12-20 23:12:51 -05:00
Anthony Sottile
829867bbda
Merge pull request #674 from amartani/master
Fix check-added-large-files --enforce-all to correctly consider all git-lfs files.
2021-12-20 23:08:08 -05:00
Alex Martani
03a65ca357 Fix check-added-large-files --enforce-all to correctly consider all git-lfs files.
`git lfs status` only outputs status for files that are pending some git-lfs related operation.
For usage with --enforce-all, we need the list of all files that are tracked, which can be
achived by `git lfs ls-files`.

Fixes: https://github.com/pre-commit/pre-commit-hooks/issues/560
2021-12-20 23:04:50 -05:00
Anthony Sottile
b8d76787ff
Merge pull request #703 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-12-20 14:46:49 -05:00
pre-commit-ci[bot]
77a394ea41
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.910-1 → v0.920](https://github.com/pre-commit/mirrors-mypy/compare/v0.910-1...v0.920)
2021-12-20 19:41:59 +00:00
Anthony Sottile
ccecdbda02
Merge pull request #689 from pujitm/master
Suggest usable call when executable files lack shebang on Windows
2021-12-07 16:03:45 -05:00
Pujit Mehrotra
16bc739ce7 Suggest usable call when exec files lack shebang on Windows
Resolves Issue #686
2021-12-07 15:53:54 -05:00
Anthony Sottile
083b0d8174
Merge pull request #692 from pre-commit/all-repos_autofix_gh-funding-default
Use org-default .github/FUNDING.yml
2021-11-23 11:53:14 -05:00
Anthony Sottile
60c1d8e12f Use org-default .github/FUNDING.yml
Committed via https://github.com/asottile/all-repos
2021-11-23 11:24:38 -05:00
Anthony Sottile
1630eb6c9e
Merge pull request #691 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-11-22 14:59:37 -05:00
pre-commit-ci[bot]
f4749f2fbb
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.29.0 → v2.29.1](https://github.com/asottile/pyupgrade/compare/v2.29.0...v2.29.1)
- [github.com/asottile/add-trailing-comma: v2.2.0 → v2.2.1](https://github.com/asottile/add-trailing-comma/compare/v2.2.0...v2.2.1)
- [github.com/asottile/setup-cfg-fmt: v1.19.0 → v1.20.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.19.0...v1.20.0)
2021-11-22 19:51:54 +00:00
Anthony Sottile
56b4a7e506
Merge pull request #682 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-11-01 15:57:24 -04:00
pre-commit-ci[bot]
bdcfb09762
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v1.18.0 → v1.19.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.18.0...v1.19.0)
2021-11-01 19:35:41 +00:00
Anthony Sottile
5b32186590
Merge pull request #678 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-10-25 12:02:58 -07:00
pre-commit-ci[bot]
d750167495
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v2.1.0 → v2.2.0](https://github.com/asottile/add-trailing-comma/compare/v2.1.0...v2.2.0)
2021-10-25 18:58:08 +00:00
Anthony Sottile
67e52cbba5
Merge pull request #677 from pre-commit/all-repos_autofix_systemexit-main
replace exit(main()) with raise SystemExit(main())
2021-10-23 11:01:09 -07:00
Anthony Sottile
39ab2ed85e replace exit(main()) with raise SystemExit(main())
Committed via https://github.com/asottile/all-repos
2021-10-23 13:23:50 -04:00
Anthony Sottile
9fc352be79
Merge pull request #676 from janosh/typos
Fix typos
2021-10-23 10:18:01 -07:00
Janosh Riebesell
05a5297dbb fix typos 2021-10-23 13:11:40 -04:00
Anthony Sottile
8559bc5936
Merge pull request #673 from revolter/fix/inconsistent-descriptions
Fix inconsistent descriptions
2021-10-20 07:06:54 -07:00
Iulian Onofrei
d7932b63a3 Fix inconsistent descriptions wording 2021-10-20 17:03:53 +03:00
Iulian Onofrei
8a1d0fcbaa Fix inconsistent descriptions punctuations 2021-10-20 17:03:53 +03:00
Iulian Onofrei
2006a4d81b Fix inconsistent descriptions positions 2021-10-20 17:02:31 +03:00
Anthony Sottile
3191f30600
Merge pull request #672 from pre-commit/non-executable
remove unneeded executable bits
2021-10-18 17:09:44 -07:00
Anthony Sottile
61357d9b36
Merge pull request #671 from dennisroche/all-lower-case
all lower-case as requested
2021-10-18 17:08:26 -07:00
Anthony Sottile
81c6c559e0 remove unneeded executable bits 2021-10-18 20:00:49 -04:00
Dennis Roche
ccaa20da8d all lower-case as requested 2021-10-18 19:58:32 -04:00
Anthony Sottile
cb02c5b460
Merge pull request #662 from errsyn/worktree_adjust_gitdir
Adjust git dir when checking for merge in worktree
2021-10-15 15:41:28 -07:00
Ersin Yildirim
07af54024c Adjust git dir when checking for merge in worktree 2021-10-15 18:23:43 -04:00
Anthony Sottile
f9ba5db3f1
Merge pull request #667 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-10-11 12:11:23 -07:00
pre-commit-ci[bot]
262c12aba2 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-10-11 18:54:31 +00:00
pre-commit-ci[bot]
633151a3df
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 3.9.2 → 4.0.1](https://github.com/PyCQA/flake8/compare/3.9.2...4.0.1)
- [github.com/asottile/setup-cfg-fmt: v1.17.0 → v1.18.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.17.0...v1.18.0)
- [github.com/pre-commit/mirrors-mypy: v0.910 → v0.910-1](https://github.com/pre-commit/mirrors-mypy/compare/v0.910...v0.910-1)
2021-10-11 18:54:03 +00:00
Anthony Sottile
1ca4ceba96
Merge pull request #661 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-10-04 12:57:48 -07:00
pre-commit-ci[bot]
3e75bdde12
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.28.0 → v2.29.0](https://github.com/asottile/pyupgrade/compare/v2.28.0...v2.29.0)
2021-10-04 18:54:32 +00:00
Anthony Sottile
e35ba8d463
Merge pull request #658 from ljmf00/add-txt-pkcs8-key
Add `PKCS #8` and OpenVPN static key blocks
2021-10-02 13:15:27 -07:00
Luís Ferreira
1b4e30e9aa
detect_private_key: add OpenVPN shared-secret key block
'OpenVPN Static key V1' label is often used by OpenVPN for providing hardening
security with additional HMAC signatures to the SSL/TLS handshake packets. They
are shared secrets and should be kept private.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-10-02 20:53:39 +01:00
Luís Ferreira
ccdf02dfd4
detect_private_key: add textual version of PKCS #8 encrypted private keys
As described by RFC7468 and RFC5958, keys that are encoded using the "ENCRYPTED
PRIVATE KEY" label are described as private key information and therefore can
contain secrets, even though encrypted.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
2021-10-02 20:53:33 +01:00
Anthony Sottile
cf059f0d24
Merge pull request #652 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-27 12:16:54 -07:00
pre-commit-ci[bot]
1822f1b60a
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.26.0 → v2.28.0](https://github.com/asottile/pyupgrade/compare/v2.26.0...v2.28.0)
2021-09-27 18:49:03 +00:00
Anthony Sottile
7eb0512c68
Merge pull request #648 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-13 12:40:35 -07:00
pre-commit-ci[bot]
5a8726e37c
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.25.0 → v2.26.0](https://github.com/asottile/pyupgrade/compare/v2.25.0...v2.26.0)
2021-09-13 18:50:52 +00:00
Anthony Sottile
96df60f75b
Merge pull request #644 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-30 15:03:41 -04:00
pre-commit-ci[bot]
3838410261
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.24.0 → v2.25.0](https://github.com/asottile/pyupgrade/compare/v2.24.0...v2.25.0)
2021-08-30 18:37:07 +00:00
Anthony Sottile
8c2e6113ec
Merge pull request #643 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-23 14:33:10 -04:00
pre-commit-ci[bot]
332a621dd9
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.3 → v2.24.0](https://github.com/asottile/pyupgrade/compare/v2.23.3...v2.24.0)
2021-08-23 18:12:39 +00:00
Anthony Sottile
25d61d4784
Merge pull request #619 from m-khvoinitsky/master
forbid-new-submodules fixes
2021-08-15 19:51:33 -04:00
Mikhail Khvoinitsky
10c5e4e166 forbid-new-submodules: fix triggering failure when only a submodule is committed (without any other file); support --from-ref and --to-ref; fixes #609 2021-08-13 21:32:08 +03:00
Anthony Sottile
f95941eae9
Merge pull request #639 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-09 11:50:39 -07:00
pre-commit-ci[bot]
5be200da58
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.1 → v2.23.3](https://github.com/asottile/pyupgrade/compare/v2.23.1...v2.23.3)
2021-08-09 18:04:14 +00:00
Anthony Sottile
8c1183c0c8
Merge pull request #637 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-02 15:30:04 -04:00
pre-commit-ci[bot]
caca3a9aec
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.0 → v2.23.1](https://github.com/asottile/pyupgrade/compare/v2.23.0...v2.23.1)
2021-08-02 18:01:41 +00:00
Anthony Sottile
4742cdf346
Merge pull request #633 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-26 14:34:47 -04:00
pre-commit-ci[bot]
5758076a55
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v2.5.0 → v2.6.0](https://github.com/asottile/reorder_python_imports/compare/v2.5.0...v2.6.0)
- [github.com/asottile/pyupgrade: v2.21.2 → v2.23.0](https://github.com/asottile/pyupgrade/compare/v2.21.2...v2.23.0)
2021-07-26 17:52:23 +00:00
Anthony Sottile
d0d9883648
Merge pull request #629 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-19 18:08:11 -04:00
pre-commit-ci[bot]
e9689b29b0
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.21.0 → v2.21.2](https://github.com/asottile/pyupgrade/compare/v2.21.0...v2.21.2)
2021-07-19 21:58:23 +00:00
Anthony Sottile
5dc21c15b2
Merge pull request #627 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-12 20:18:24 -04:00
pre-commit-ci[bot]
b008acc8b6
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.20.0 → v2.21.0](https://github.com/asottile/pyupgrade/compare/v2.20.0...v2.21.0)
2021-07-12 23:21:11 +00:00
Anthony Sottile
fe1db5fdb6
Merge pull request #626 from guykisel/case_conflict_performance
optimize check_case_conflict.parents
2021-07-10 12:45:01 -04:00
Guy Kisel
2468167371 remove unused os.path 2021-07-09 12:29:20 -07:00
Guy Kisel
8a4333fcff optimize check_case_conflict.parents 2021-07-09 12:26:07 -07:00
Anthony Sottile
e71fd49e70
Merge pull request #623 from pre-commit/py3-plus-which
use shutil.which instead of distutils.spawn
2021-07-07 14:09:09 -04:00
Anthony Sottile
301195efa9 use shutil.which instead of distutils.spawn 2021-07-07 14:06:01 -04:00
Anthony Sottile
8fa80b3606
Merge pull request #621 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-05 18:10:07 -04:00
pre-commit-ci[bot]
469e4b83f5
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.19.4 → v2.20.0](https://github.com/asottile/pyupgrade/compare/v2.19.4...v2.20.0)
2021-07-05 22:02:26 +00:00
Anthony Sottile
a7a4670f98
Merge pull request #620 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-06-28 18:14:34 -07:00
pre-commit-ci[bot]
de3f6c33c7
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-mypy: v0.902 → v0.910](https://github.com/pre-commit/mirrors-mypy/compare/v0.902...v0.910)
2021-06-28 17:37:51 +00:00
Anthony Sottile
b84362dd9a
Merge pull request #618 from pre-commit/all-repos_autofix_mypy-settings
stricter mypy settings
2021-06-21 19:42:15 -07:00
Anthony Sottile
8041dff63f stricter mypy settings
Committed via https://github.com/asottile/all-repos
2021-06-21 19:15:42 -07:00
Anthony Sottile
0bedbb96b9
Merge pull request #614 from cansarigol/pdbr-debug-statements
Added pdbr into debug statements
2021-06-15 07:10:05 -07:00
Can Sarıgöl
41b29e8c8d
Added pdbr into debug statements 2021-06-15 09:28:11 +02:00
Anthony Sottile
252f04654d
Merge pull request #613 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-06-14 11:52:53 -07:00
Anthony Sottile
fabe3d8855
Add mypy dependency on types-all 2021-06-14 11:30:37 -07:00
pre-commit-ci[bot]
172a87e6a8
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.19.1 → v2.19.4](https://github.com/asottile/pyupgrade/compare/v2.19.1...v2.19.4)
- [github.com/pre-commit/mirrors-mypy: v0.812 → v0.902](https://github.com/pre-commit/mirrors-mypy/compare/v0.812...v0.902)
2021-06-14 17:34:07 +00:00
Anthony Sottile
44effd2842
Merge pull request #611 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-06-07 18:51:05 -07:00
pre-commit-ci[bot]
00948d0833
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.19.0 → v2.19.1](https://github.com/asottile/pyupgrade/compare/v2.19.0...v2.19.1)
2021-06-08 01:46:25 +00:00
Anthony Sottile
f48244a805
Merge pull request #607 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-31 10:56:53 -07:00
pre-commit-ci[bot]
2d040b429d
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.18.2 → v2.19.0](https://github.com/asottile/pyupgrade/compare/v2.18.2...v2.19.0)
2021-05-31 17:25:23 +00:00
Anthony Sottile
371a07eb4c
Merge pull request #606 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-24 11:19:36 -07:00
pre-commit-ci[bot]
a4f7dedfed
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.16.0 → v2.18.2](https://github.com/asottile/pyupgrade/compare/v2.16.0...v2.18.2)
2021-05-24 17:20:10 +00:00
Anthony Sottile
7282c4b849
Merge pull request #604 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-17 11:18:53 -07:00
pre-commit-ci[bot]
d1fac7f826
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.15.0 → v2.16.0](https://github.com/asottile/pyupgrade/compare/v2.15.0...v2.16.0)
2021-05-17 17:23:36 +00:00
Anthony Sottile
38b88246cc v4.0.1 2021-05-16 08:29:57 -07:00
Anthony Sottile
0e40c1d61b
Merge pull request #603 from scop/check_shebang_scripts_are_executable-entrypoint
fix: check-shebang-scripts-are-executable entry point
2021-05-16 08:27:57 -07:00
Ville Skyttä
bb4eef160d fix: check-shebang-scripts-are-executable entry point
Closes https://github.com/pre-commit/pre-commit-hooks/issues/602
2021-05-16 13:23:23 +03:00
Anthony Sottile
dd3444783f
Merge pull request #601 from ibLeDy/fix/check-json-hook-failing
Fix `check-json` failing on ci runs
2021-05-15 07:35:35 -07:00
Iago Alonso
fed8b6debb
Rename file causing check-json to fail
- `mv duplicated_key_json.{json,notjson}`
- change reference to the file in `tests/check_json_test.py`

Fixes #600
2021-05-15 12:31:33 +02:00
Anthony Sottile
9cc62e1a63 v4.0.0 2021-05-14 20:17:35 -07:00
Anthony Sottile
b0b1a413c6
Merge pull request #599 from pre-commit/all-repos_autofix_more-inclusive-language
Use more inclusive language
2021-05-14 19:22:48 -07:00
Anthony Sottile
a5cf10d9b2 Use more inclusive language
Committed via https://github.com/asottile/all-repos
2021-05-14 19:12:09 -07:00
Anthony Sottile
11a996eec6
Merge pull request #597 from pre-commit/remove-deprecated
remove deprecated autopep8-wrapper, flake8, pyflakes
2021-05-11 13:16:53 -07:00
Anthony Sottile
1995abf556 remove deprecated autopep8-wrapper, flake8, pyflakes 2021-05-11 13:09:44 -07:00
Anthony Sottile
868784a49c
Merge pull request #595 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-10 14:08:46 -07:00
pre-commit-ci[bot]
f90bef2772
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 3.9.1 → 3.9.2](https://github.com/PyCQA/flake8/compare/3.9.1...3.9.2)
- [github.com/asottile/pyupgrade: v2.14.0 → v2.15.0](https://github.com/asottile/pyupgrade/compare/v2.14.0...v2.15.0)
2021-05-10 20:21:04 +00:00
Anthony Sottile
11cdc8d820
Merge pull request #545 from scop/check-shebangs-executable
Add check for executability of scripts with shebangs
2021-05-04 18:49:58 -07:00
Ville Skyttä
391ae30a64 Add check for executability of scripts with shebangs
Closes https://github.com/pre-commit/pre-commit-hooks/issues/543
2021-05-04 18:45:43 -07:00
Ville Skyttä
9e7cd9f13a Refactor check_executables_have_shebangs for git ls-files reuse 2021-05-04 18:45:42 -07:00
Anthony Sottile
6c99eceab7
Merge pull request #593 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-03 10:27:13 -07:00
pre-commit-ci[bot]
4342783e1e
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/mirrors-autopep8: v1.5.6 → v1.5.7](https://github.com/pre-commit/mirrors-autopep8/compare/v1.5.6...v1.5.7)
- [github.com/asottile/pyupgrade: v2.13.0 → v2.14.0](https://github.com/asottile/pyupgrade/compare/v2.13.0...v2.14.0)
2021-05-03 17:17:27 +00:00
Anthony Sottile
17875b1017
Merge pull request #591 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-26 11:05:23 -07:00
pre-commit-ci[bot]
0423b8b21f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v2.4.0 → v2.5.0](https://github.com/asottile/reorder_python_imports/compare/v2.4.0...v2.5.0)
- [github.com/asottile/pyupgrade: v2.12.0 → v2.13.0](https://github.com/asottile/pyupgrade/compare/v2.12.0...v2.13.0)
2021-04-26 17:18:44 +00:00
Anthony Sottile
9ee77bd5a2
Merge pull request #588 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-19 11:43:00 -07:00
pre-commit-ci[bot]
b5d10ac89f
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 3.9.0 → 3.9.1](https://github.com/PyCQA/flake8/compare/3.9.0...3.9.1)
2021-04-19 17:08:17 +00:00
Anthony Sottile
1f4a42ab05
Merge pull request #587 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-12 10:30:46 -07:00
pre-commit-ci[bot]
1fa820c847
[pre-commit.ci] pre-commit autoupdate 2021-04-12 17:10:06 +00:00
Anthony Sottile
2f7e22dc21
Merge pull request #585 from pre-commit/all-repos_autofix_azure-pipelines-autoupdate
Update azure-pipelines template repositories
2021-04-08 19:40:51 -07:00
Anthony Sottile
f5e71a3ddd Update azure-pipelines template repositories
Committed via https://github.com/asottile/all-repos
2021-04-08 19:22:22 -07:00
Anthony Sottile
cfc3672e46
Merge pull request #582 from jack1142/allow_any_branch_name
Disallow any branch name in checks_vcs_permalinks
2021-04-06 18:33:00 -07:00
jack1142
4729918bc9 Disallow any branch name in checks_vcs_permalinks 2021-04-06 18:19:19 -07:00
Anthony Sottile
4195f4d271
Merge pull request #580 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-05 11:30:45 -07:00
pre-commit-ci[bot]
45e252fc16
[pre-commit.ci] pre-commit autoupdate 2021-04-05 17:08:26 +00:00
Anthony Sottile
ae4753139b
Merge pull request #575 from slsyy/master
check also directories in check_case_conflict
2021-04-04 09:39:24 -07:00
Krystian Chmura
f681234a0e check also directories in check_case_conflict
fix #70
2021-04-04 09:27:44 -07:00
Anthony Sottile
3db0cc5b2e
Merge pull request #576 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-22 12:10:54 -07:00
pre-commit-ci[bot]
1cfedf373e
[pre-commit.ci] pre-commit autoupdate 2021-03-22 17:03:46 +00:00
Anthony Sottile
d34222bfa8
Merge pull request #571 from jack1142/patch-1
Update `pretty-format-json` to write to stdout with utf-8 encoding
2021-03-15 17:52:13 -07:00
jack1142
1de4fe6b42 Update pretty-format-json to write to stdout with utf-8 encoding 2021-03-15 17:48:24 -07:00
Anthony Sottile
0c033f760e
Merge pull request #572 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-15 12:15:45 -07:00
pre-commit-ci[bot]
c144e2b5b1 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-03-15 17:01:52 +00:00
pre-commit-ci[bot]
4dcbacbeb0
[pre-commit.ci] pre-commit autoupdate 2021-03-15 17:00:31 +00:00
Anthony Sottile
2618198e96
Merge pull request #565 from ndevenish/no_commit_main_default
no-commit-to-branch: Add 'main' to branches blocked by default
2021-03-04 11:03:15 -08:00
Nicholas Devenish
3abbd4785c no-commit-to-branch: Default to both master and main 2021-03-04 15:59:25 +00:00
Anthony Sottile
51e14fcc97
Merge pull request #562 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-22 09:35:07 -08:00
pre-commit-ci[bot]
d90e97da29
[pre-commit.ci] pre-commit autoupdate 2021-02-22 17:03:23 +00:00
Anthony Sottile
cefb9ed975
Merge pull request #558 from AdityaKhursale/master
Report duplicate keys in check_json
2021-02-18 13:57:15 -08:00
Aditya Khursale
fe37451719 Report duplicate keys in check_json
Raise ValueError and return 1 if json contains duplicate keys
2021-02-18 13:53:57 -08:00
Anthony Sottile
11a2fdbab8
Merge pull request #556 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-08 09:14:23 -08:00
pre-commit-ci[bot]
aaa5981ebd
[pre-commit.ci] pre-commit autoupdate 2021-02-08 16:49:38 +00:00
Anthony Sottile
fb9fc7b71b
Merge pull request #553 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-01 12:46:25 -08:00
pre-commit-ci[bot]
81226d2cf4
[pre-commit.ci] pre-commit autoupdate 2021-02-01 16:48:14 +00:00
Anthony Sottile
3842bea65a
Merge pull request #551 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-01-25 08:46:25 -08:00
pre-commit-ci[bot]
a3a8d29b14
[pre-commit.ci] pre-commit autoupdate 2021-01-25 16:39:55 +00:00
Anthony Sottile
43f5ffaeab
Merge pull request #549 from greshilov/fix-comments-with-indents
Fix comments with indents
2021-01-17 12:13:20 -08:00
Viacheslav Greshilov
28b2c8e431 requirements-txt-fixer now supports indents before comments 2021-01-17 21:15:05 +02:00
Anthony Sottile
a6add1c672
Merge pull request #544 from scop/check_executable_opt
check_executables_have_shebangs: avoid unneeded shebang reads on win32
2021-01-08 08:50:39 -08:00
Ville Skyttä
dae0cbd2fa check_executables_have_shebangs: avoid unneeded shebang reads on win32 2021-01-08 16:22:33 +02:00
Anthony Sottile
208e6e3692
Merge pull request #542 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-01-04 09:19:53 -08:00
pre-commit-ci[bot]
2082204791
[pre-commit.ci] pre-commit autoupdate 2021-01-04 16:43:45 +00:00
Anthony Sottile
47561b98ca
Merge pull request #540 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2020-12-21 09:37:40 -08:00
pre-commit-ci[bot]
19be557505
[pre-commit.ci] pre-commit autoupdate 2020-12-21 16:44:37 +00:00
Anthony Sottile
6e2418c552 v3.4.0 2020-12-15 13:46:40 -08:00
Anthony Sottile
234534dbc6
Merge pull request #538 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2020-12-14 09:15:49 -08:00
pre-commit-ci[bot]
c4f18bab1a
[pre-commit.ci] pre-commit autoupdate 2020-12-14 16:35:17 +00:00
Anthony Sottile
b7603bf928
Merge pull request #533 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2020-11-30 08:51:13 -08:00
pre-commit-ci[bot]
1c39c70d88
[pre-commit.ci] pre-commit autoupdate 2020-11-30 16:30:53 +00:00
Anthony Sottile
5c5c6c516a
Merge pull request #532 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2020-11-23 08:48:31 -08:00
pre-commit-ci[bot]
07699f5dae
[pre-commit.ci] pre-commit autoupdate 2020-11-23 16:40:39 +00:00
Anthony Sottile
c96e4b7cba
Merge pull request #531 from pre-commit/all-repos_autofix_gh-sponsors
Add link to GitHub Sponsors + Open Collective
2020-11-19 17:28:38 -08:00
Anthony Sottile
e3f0f5cec2 Add link to GitHub Sponsors + Open Collective
at the time of writing I am currently unemployed.  I'd love to make open
source a full time career.  if you or your company is deriving value from
this free software, please consider [sponsoring] or [supporting].

[sponsoring]: https://github.com/sponsors/asottile
[supporting]: https://opencollective.com/pre-commit

Committed via https://github.com/asottile/all-repos
2020-11-19 17:13:08 -08:00
Anthony Sottile
4b863f1272
Merge pull request #511 from m-khvoinitsky/master
New hook 'destroyed-symlinks'
2020-11-18 11:48:14 -08:00
Mikhail Khvoinitsky
1e87d59a2d New hook 'destroyed-symlinks' to detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to; move zsplit to util 2020-11-18 11:45:05 -08:00
Anthony Sottile
14e9f0e512
Merge pull request #530 from youngminz/master
Add --additional-domain to check-vcs-permalinks
2020-11-18 09:03:57 -08:00
Youngmin Koo
1f8151aeeb Add --additional-github-domain to check-vcs-permalinks 2020-11-18 08:58:23 -08:00
Anthony Sottile
2323ac0558
Merge pull request #529 from pre-commit/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2020-11-16 10:44:21 -08:00
Anthony Sottile
64d3fbd5cf fix mypy by correcting the __lt__ annotation 2020-11-16 10:41:32 -08:00
pre-commit-ci[bot]
e90998353b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2020-11-16 17:05:15 +00:00
pre-commit-ci[bot]
29fc56c40c [pre-commit.ci] pre-commit autoupdate 2020-11-16 17:04:49 +00:00
Anthony Sottile
75ade3bf9b
Merge pull request #525 from pre-commit/pci
use pre-commit.ci
2020-10-29 11:42:11 -07:00
Anthony Sottile
7d9c32e9a0 use pre-commit.ci 2020-10-29 11:38:19 -07:00
Anthony Sottile
8bb0054677
Merge pull request #524 from danielhoherd/sort-unique
Add --unique arg to file_contents_sorter
2020-10-25 12:26:47 -07:00
Daniel Hoherd
7e393476bd Add --unique arg to file-contents-sorter 2020-10-25 12:18:09 -07:00
Anthony Sottile
9136088a24 v3.3.0 2020-10-20 10:17:01 -07:00
Anthony Sottile
08d19018ce
Merge pull request #522 from jgowdy/byte-order-marker-fix
Attempt to add fixing of BOMs
2020-10-11 11:35:09 -07:00
Jeremiah Gowdy
d18bd5b75f Add new byte-order-marker checker/fixer 2020-10-11 11:31:05 -07:00
Anthony Sottile
5bd9e74adf
Merge pull request #519 from mshawcroft/fix-518
Fix #518, provide --enforce-all option to check_added_large_files
2020-09-27 15:25:47 -07:00
Marcus Shawcroft
012bb0691f Fix #518, provide --enforce-all option to check_added_large_files
The --enforce-all option when provided ensures that all files passed
on the command line are checked against the size limit.  Default
behaviour remains unchanged.
2020-09-27 15:15:37 -07:00
Anthony Sottile
31d41ff291
Merge pull request #514 from Julian/case-insensitive-sorting
Add a way to do case-insensitive sorting via file-contents-sorter.
2020-08-26 18:59:21 -07:00
Julian Berman
0c760253f3 Add a way to do case-insensitive sorting via file-contents-sorter. 2020-08-26 21:55:22 -04:00
Anthony Sottile
e1668fe86a v3.2.0 2020-07-30 13:33:26 -07:00
Anthony Sottile
9eab799c5a
Merge pull request #509 from pawamoy/patch-1
Fix parsing of git output with unusual characters
2020-07-30 12:03:39 -07:00
Timothée Mazzucotelli
4faed34fbc Fix parsing of git output with unusual characters
On Windows, all files are "executable".
Therefore, to know if a file is supposed to be executed,
we check how its attributes were recorded by git:
we run a `git ls-files` command in a subprocess.

By default, this command outputs information
on multiple lines (file and their data separated by newlines).
When a file contains an unusual character,
the character is escaped with an integer sequence
(such as `\303\261`), and git wraps the whole filename
in double-quotes because of the backslashes.
It breaks the current code because we try to open
the filename containing the double-quotes:
it doesn't exist, of course.

Instead of trying to fix this special case by removing
the double-quotes, and breaking other cases
(a double-quote is a valid filename character on Linux),
we tell git to separate each item with the null character `\0`
instead of a new line `\n`, with the option `-z`.
With this option, git doesn't escape unusual characters
with integer sequence, so the output is fixed, and we
parse it by splitting on `\0` instead of `\n`.

Fixes #508.
2020-07-30 11:58:24 -07:00
Anthony Sottile
5372f44b85
Merge pull request #502 from jgeerds/feature/catch-pydevd-pycharm-debug-statement
debug-statements: Add "pydevd_pycharm" to list of debug statements
2020-07-01 17:03:04 -07:00
Jascha Geerds
53a05b952c Add "pydevd_pycharm" to list of debug statements 2020-07-01 17:15:46 +02:00
Anthony Sottile
f7dd0c05bd
Merge pull request #501 from marcjay/document-no-commit-to-branch-always-run
Document the default always_run behaviour of no-commit-to-branch
2020-06-19 13:31:37 -07:00
Marc Jay
b4694348b0 Document the default always_run behaviour of no-commit-to-branch
Include instructions on how to use files/types/excludes/exclude_types
with the no-commit-to-branch hook, along with the caveat of it allowing
empty commits
2020-06-19 18:39:45 +01:00
Anthony Sottile
c14b3aa54f sed -i s/whitelist/allowlist/g 2020-06-17 08:27:11 -07:00
Anthony Sottile
f0bf512dbb
Merge pull request #491 from pre-commit/all-repos_autofix_faster-tests
slightly speed up tests by avoiding pre-commit install
2020-05-26 22:07:40 -07:00
Anthony Sottile
1da4a7f296 slightly speed up tests by avoiding pre-commit install
Committed via https://github.com/asottile/all-repos
2020-05-26 21:53:22 -07:00
Anthony Sottile
0e509ddcbc
Merge pull request #488 from mxr/strpath
Don't use LocalPath.strpath
2020-05-20 10:32:27 -07:00
Max Rozentsveyg
f35bfed79e Don't use LocalPath.strpath 2020-05-20 12:08:42 -04:00
83 changed files with 1864 additions and 922 deletions

19
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,19 @@
name: main
on:
push:
branches: [main, test-me-*]
tags: '*'
pull_request:
jobs:
main-windows:
uses: asottile/workflows/.github/workflows/tox.yml@v1.8.1
with:
env: '["py310"]'
os: windows-latest
main-linux:
uses: asottile/workflows/.github/workflows/tox.yml@v1.8.1
with:
env: '["py310", "py311", "py312", "py313"]'
os: ubuntu-latest

5
.gitignore vendored
View file

@ -3,9 +3,4 @@
.*.sw[a-z]
.coverage
.tox
.venv.touch
/.mypy_cache
/.pytest_cache
/venv*
coverage-html
dist

View file

@ -1,50 +1,41 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-added-large-files
- id: check-yaml
- id: debug-statements
- id: name-tests-test
- id: double-quote-string-fixer
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.0
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports==1.7.0]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.2
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit
rev: v2.4.0
hooks:
- id: validate_manifest
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.3.0
hooks:
- id: reorder-python-imports
args: [--py3-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v2.4.1
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.0.1
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.9.0
rev: v3.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.16.0
hooks:
- id: reorder-python-imports
args: [--py310-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v4.0.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py310-plus]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.2
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/flake8
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.770
rev: v1.19.1
hooks:
- id: mypy

View file

@ -1,195 +1,212 @@
- id: autopep8-wrapper
name: autopep8 wrapper (removed)
description: (removed) use pre-commit/mirrors-autopep8 instead.
entry: pre-commit-hooks-removed autopep8-wrapper autopep8 https://github.com/pre-commit/mirrors-autopep8
language: python
always_run: true
pass_filenames: false
- id: check-added-large-files
name: Check for added large files
description: Prevent giant files from being committed
name: check for added large files
description: prevents giant files from being committed.
entry: check-added-large-files
language: python
stages: [pre-commit, pre-push, manual]
minimum_pre_commit_version: 3.2.0
- id: check-ast
name: Check python ast
description: Simply check whether the files parse as valid python.
name: check python ast
description: simply checks whether the files parse as valid python.
entry: check-ast
language: python
types: [python]
- id: check-byte-order-marker
name: Check for byte-order marker
description: Forbid files which have a UTF-8 byte-order marker
entry: check-byte-order-marker
name: check-byte-order-marker (removed)
description: (removed) use fix-byte-order-marker instead.
entry: pre-commit-hooks-removed check-byte-order-marker fix-byte-order-marker https://github.com/pre-commit/pre-commit-hooks
language: python
types: [text]
- id: check-builtin-literals
name: Check builtin type constructor use
description: Require literal syntax when initializing empty or zero Python builtin types.
name: check builtin type constructor use
description: requires literal syntax when initializing empty or zero python builtin types.
entry: check-builtin-literals
language: python
types: [python]
- id: check-case-conflict
name: Check for case conflicts
description: Check for files that would conflict in case-insensitive filesystems
name: check for case conflicts
description: checks for files that would conflict in case-insensitive filesystems.
entry: check-case-conflict
language: python
- id: check-docstring-first
name: Check docstring is first
description: Checks a common error of defining a docstring after code.
name: check docstring is first (deprecated)
description: checks a common error of defining a docstring after code.
entry: check-docstring-first
language: python
types: [python]
- id: check-executables-have-shebangs
name: Check that executables have shebangs
description: Ensures that (non-binary) executables have a shebang.
name: check that executables have shebangs
description: ensures that (non-binary) executables have a shebang.
entry: check-executables-have-shebangs
language: python
types: [text, executable]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
minimum_pre_commit_version: 3.2.0
- id: check-illegal-windows-names
name: check illegal windows names
entry: Illegal Windows filenames detected
language: fail
files: '(?i)((^|/)(CON|PRN|AUX|NUL|COM[\d¹²³]|LPT[\d¹²³])(\.|/|$)|[<>:\"\\|?*\x00-\x1F]|/[^/]*[\.\s]/|[^/]*[\.\s]$)'
- id: check-json
name: Check JSON
description: This hook checks json files for parseable syntax.
name: check json
description: checks json files for parseable syntax.
entry: check-json
language: python
types: [json]
- id: check-shebang-scripts-are-executable
name: check that scripts with shebangs are executable
description: ensures that (non-binary) files with a shebang are executable.
entry: check-shebang-scripts-are-executable
language: python
types: [text]
stages: [pre-commit, pre-push, manual]
minimum_pre_commit_version: 3.2.0
- id: pretty-format-json
name: Pretty format JSON
description: This hook sets a standard for formatting JSON files.
name: pretty format json
description: sets a standard for formatting json files.
entry: pretty-format-json
language: python
types: [json]
- id: check-merge-conflict
name: Check for merge conflicts
description: Check for files that contain merge conflict strings.
name: check for merge conflicts
description: checks for files that contain merge conflict strings.
entry: check-merge-conflict
language: python
types: [text]
- id: check-symlinks
name: Check for broken symlinks
description: Checks for symlinks which do not point to anything.
name: check for broken symlinks
description: checks for symlinks which do not point to anything.
entry: check-symlinks
language: python
types: [symlink]
- id: check-toml
name: Check Toml
description: This hook checks toml files for parseable syntax.
name: check toml
description: checks toml files for parseable syntax.
entry: check-toml
language: python
types: [toml]
- id: check-vcs-permalinks
name: Check vcs permalinks
description: Ensures that links to vcs websites are permalinks.
name: check vcs permalinks
description: ensures that links to vcs websites are permalinks.
entry: check-vcs-permalinks
language: python
types: [text]
- id: check-xml
name: Check Xml
description: This hook checks xml files for parseable syntax.
name: check xml
description: checks xml files for parseable syntax.
entry: check-xml
language: python
types: [xml]
- id: check-yaml
name: Check Yaml
description: This hook checks yaml files for parseable syntax.
name: check yaml
description: checks yaml files for parseable syntax.
entry: check-yaml
language: python
types: [yaml]
- id: debug-statements
name: Debug Statements (Python)
description: Check for debugger imports and py37+ `breakpoint()` calls in python source.
name: debug statements (python)
description: checks for debugger imports and py37+ `breakpoint()` calls in python source.
entry: debug-statement-hook
language: python
types: [python]
- id: destroyed-symlinks
name: detect destroyed symlinks
description: detects symlinks which are changed to regular files with a content of a path which that symlink was pointing to.
entry: destroyed-symlinks
language: python
types: [file]
stages: [pre-commit, pre-push, manual]
- id: detect-aws-credentials
name: Detect AWS Credentials
description: Detects *your* aws credentials from the aws cli credentials file
name: detect aws credentials
description: detects *your* aws credentials from the aws cli credentials file.
entry: detect-aws-credentials
language: python
types: [text]
- id: detect-private-key
name: Detect Private Key
description: Detects the presence of private keys
name: detect private key
description: detects the presence of private keys.
entry: detect-private-key
language: python
types: [text]
- id: double-quote-string-fixer
name: Fix double quoted strings
description: This hook replaces double quoted strings with single quoted strings
name: fix double quoted strings
description: replaces double quoted strings with single quoted strings.
entry: double-quote-string-fixer
language: python
types: [python]
- id: end-of-file-fixer
name: Fix End of Files
description: Ensures that a file is either empty, or ends with one newline.
name: fix end of files
description: ensures that a file is either empty, or ends with one newline.
entry: end-of-file-fixer
language: python
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
minimum_pre_commit_version: 3.2.0
- id: file-contents-sorter
name: File Contents Sorter
description: Sort the lines in specified files (defaults to alphabetical). You must provide list of target files as input in your .pre-commit-config.yaml file.
name: file contents sorter
description: sorts the lines in specified files (defaults to alphabetical). you must provide list of target files as input in your .pre-commit-config.yaml file.
entry: file-contents-sorter
language: python
files: '^$'
- id: fix-byte-order-marker
name: fix utf-8 byte order marker
description: removes utf-8 byte order marker.
entry: fix-byte-order-marker
language: python
types: [text]
- id: fix-encoding-pragma
name: Fix python encoding pragma
name: fix python encoding pragma (removed)
description: (removed) use pyupgrade instead.
entry: pre-commit-hooks-removed fix-encoding-pragma pyupgrade https://github.com/asottile/pyupgrade
language: python
entry: fix-encoding-pragma
description: 'Add # -*- coding: utf-8 -*- to the top of python files'
types: [python]
- id: flake8
name: Flake8 (removed)
description: (removed) use gitlab.com/pycqa/flake8 instead.
entry: pre-commit-hooks-removed flake8 flake8 https://gitlab.com/pycqa/flake8
language: python
always_run: true
pass_filenames: false
- id: forbid-new-submodules
name: Forbid new submodules
name: forbid new submodules
description: prevents addition of new git submodules.
language: python
entry: forbid-new-submodules
description: Prevent addition of new git submodules
types: [directory]
- id: forbid-submodules
name: forbid submodules
description: forbids any submodules in the repository
language: fail
entry: 'submodules are not allowed in this repository:'
types: [directory]
- id: mixed-line-ending
name: Mixed line ending
description: Replaces or checks mixed line ending
name: mixed line ending
description: replaces or checks mixed line ending.
entry: mixed-line-ending
language: python
types: [text]
- id: name-tests-test
name: Tests should end in _test.py
description: This verifies that test files are named correctly
name: python tests naming
description: verifies that test files are named correctly.
entry: name-tests-test
language: python
files: (^|/)tests/.+\.py$
- id: no-commit-to-branch
name: "Don't commit to branch"
name: "don't commit to branch"
entry: no-commit-to-branch
language: python
pass_filenames: false
always_run: true
- id: pyflakes
name: Pyflakes (removed)
description: (removed) use gitlab.com/pycqa/flake8 instead.
entry: pre-commit-hooks-removed pyflakes flake8 https://gitlab.com/pycqa/flake8
language: python
always_run: true
pass_filenames: false
- id: requirements-txt-fixer
name: Fix requirements.txt
description: Sorts entries in requirements.txt
name: fix requirements.txt
description: sorts entries in requirements.txt.
entry: requirements-txt-fixer
language: python
files: requirements.*\.txt$
files: (requirements|constraints).*\.txt$
- id: sort-simple-yaml
name: Sort simple YAML files
name: sort simple yaml files
description: sorts simple yaml files which consist only of top-level keys, preserving comments and blocks.
language: python
entry: sort-simple-yaml
description: Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks.
files: '^$'
- id: trailing-whitespace
name: Trim Trailing Whitespace
description: This hook trims trailing whitespace.
name: trim trailing whitespace
description: trims trailing whitespace.
entry: trailing-whitespace-fixer
language: python
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
minimum_pre_commit_version: 3.2.0

View file

@ -1,3 +1,255 @@
6.0.0 - 2025-08-09
==================
## Fixes
- `check-shebang-scripts-are-executable`: improve error message.
- #1115 PR by @homebysix.
## Migrating
- now requires python >= 3.9.
- #1098 PR by @asottile.
- `file-contents-sorter`: disallow `--unique` and `--ignore-case` at the same
time.
- #1095 PR by @nemacysts.
- #794 issue by @teksturi.
- Removed `check-byte-order-marker` and `fix-encoding-pragma`.
- `check-byte-order-marker`: migrate to `fix-byte-order-marker`.
- `fix-encoding-pragma`: migrate to `pyupgrade`.
- #1034 PR by @mxr.
- #1032 issue by @mxr.
- #522 PR by @jgowdy.
5.0.0 - 2024-10-05
==================
### Features
- `requirements-txt-fixer`: also remove `pkg_resources==...`.
- #850 PR by @ericfrederich.
- #1030 issue by @ericfrederich.
- `check-illegal-windows-names`: new hook!
- #1044 PR by @ericfrederich.
- #589 issue by @ericfrederich.
- #1049 PR by @Jeffrey-Lim.
- `pretty-format-json`: continue processing even if a file has a json error.
- #1039 PR by @amarvin.
- #1038 issue by @amarvin.
### Fixes
- `destroyed-symlinks`: set `stages` to `[pre-commit, pre-push, manual]`
- PR #1085 by @AdrianDC.
### Migrating
- pre-commit-hooks now requires `pre-commit>=3.2.0`.
- use non-deprecated names for `stages`.
- #1093 PR by @asottile.
4.6.0 - 2024-04-06
==================
### Features
- `requirements-txt-fixer`: remove duplicate packages.
- #1014 PR by @vhoulbreque-withings.
- #960 issue @csibe17.
### Migrating
- `fix-encoding-pragma`: deprecated -- will be removed in 5.0.0. use
[pyupgrade](https://github.com/asottile/pyupgrade) or some other tool.
- #1033 PR by @mxr.
- #1032 issue by @mxr.
4.5.0 - 2023-10-07
==================
### Features
- `requirements-txt-fixer`: also sort `constraints.txt` by default.
- #857 PR by @lev-blit.
- #830 issue by @PLPeeters.
- `debug-statements`: add `bpdb` debugger.
- #942 PR by @mwip.
- #941 issue by @mwip.
### Fixes
- `file-contents-sorter`: fix sorting an empty file.
- #944 PR by @RoelAdriaans.
- #935 issue by @paduszyk.
- `double-quote-string-fixer`: don't rewrite inside f-strings in 3.12+.
- #973 PR by @asottile.
- #971 issue by @XuehaiPan.
## Migrating
- now requires python >= 3.8.
- #926 PR by @asottile.
- #927 PR by @asottile.
4.4.0 - 2022-11-23
==================
### Features
- `forbid-submodules`: new hook which outright bans submodules.
- #815 PR by @asottile.
- #707 issue by @ChiefGokhlayeh.
4.3.0 - 2022-06-07
==================
### Features
- `check-executables-have-shebangs`: use `git config core.fileMode` to
determine if it should query `git`.
- #730 PR by @Kurt-von-Laven.
- `name-tests-test`: add `--pytest-test-first` test convention.
- #779 PR by @asottile.
### Fixes
- `check-shebang-scripts-are-executable`: update windows instructions.
- #774 PR by @mdeweerd.
- #770 issue by @mdeweerd.
- `check-toml`: use stdlib `tomllib` when available.
- #771 PR by @DanielNoord.
- #755 issue by @sognetic.
- `check-added-large-files`: don't run on non-file `stages`.
- #778 PR by @asottile.
- #777 issue by @skyj.
4.2.0 - 2022-04-06
==================
### Features
- `name-tests-test`: updated display text.
- #713 PR by @asottile.
- `check-docstring-first`: make output more parsable.
- #748 PR by @asottile.
- `check-merge-conflict`: make output more parsable.
- #748 PR by @asottile.
- `debug-statements`: make output more parsable.
- #748 PR by @asottile.
### Fixes
- `check-merge-conflict`: fix detection of `======` conflict marker on windows.
- #748 PR by @asottile.
### Updating
- Drop python<3.7.
- #719 PR by @asottile.
- Changed default branch from `master` to `main`.
- #744 PR by @asottile.
4.1.0 - 2021-12-22
==================
### Features
- `debug-statements`: add `pdbr` debugger.
- #614 PR by @cansarigol.
- `detect-private-key`: add detection for additional key types.
- #658 PR by @ljmf00.
- `check-executables-have-shebangs`: improve messaging on windows.
- #689 PR by @pujitm.
- #686 issue by @jmerdich.
- `check-added-large-files`: support `--enforce-all` with `git-lfs`.
- #674 PR by @amartani.
- #560 issue by @jeremy-coulon.
### Fixes
- `check-case-conflict`: improve performance.
- #626 PR by @guykisel.
- #625 issue by @guykisel.
- `forbid-new-submodules`: fix false-negatives for `pre-push`.
- #619 PR by @m-khvoinitsky.
- #609 issue by @m-khvoinitsky.
- `check-merge-conflict`: fix execution in git worktrees.
- #662 PR by @errsyn.
- #638 issue by @daschuer.
### Misc.
- Normalize case of hook names and descriptions.
- #671 PR by @dennisroche.
- #673 PR by @revolter.
4.0.1 - 2021-05-16
==================
### Fixes
- `check-shebang-scripts-are-executable` fix entry point.
- #602 issue by @Person-93.
- #603 PR by @scop.
4.0.0 - 2021-05-14
==================
### Features
- `check-json`: report duplicate keys.
- #558 PR by @AdityaKhursale.
- #554 issue by @adamchainz.
- `no-commit-to-branch`: add `main` to default blocked branches.
- #565 PR by @ndevenish.
- `check-case-conflict`: check conflicts in directory names as well.
- #575 PR by @slsyy.
- #70 issue by @andyjack.
- `check-vcs-permalinks`: forbid other branch names.
- #582 PR by @jack1142.
- #581 issue by @jack1142.
- `check-shebang-scripts-are-executable`: new hook which ensures shebang'd
scripts are executable.
- #545 PR by @scop.
### Fixes
- `check-executables-have-shebangs`: Short circuit shebang lookup on windows.
- #544 PR by @scop.
- `requirements-txt-fixer`: Fix comments which have indentation
- #549 PR by @greshilov.
- #548 issue by @greshilov.
- `pretty-format-json`: write to stdout using UTF-8 encoding.
- #571 PR by @jack1142.
- #570 issue by @jack1142.
- Use more inclusive language.
- #599 PR by @asottile.
### Breaking changes
- Remove deprecated hooks: `flake8`, `pyflakes`, `autopep8-wrapper`.
- #597 PR by @asottile.
3.4.0 - 2020-12-15
==================
### Features
- `file-contents-sorter`: Add `--unique` argument
- #524 PR by @danielhoherd.
- `check-vcs-permalinks`: Add `--additional-github-domain` option
- #530 PR by @youngminz.
- New hook: `destroyed-symlinks` to detect unintentional symlink-breakages on
windows.
- #511 PR by @m-khvoinitsky.
3.3.0 - 2020-10-20
==================
### Features
- `file-contents-sorter`: add `--ignore-case` option for case-insensitive
sorting
- #514 PR by @Julian.
- `check-added-large-files`: add `--enforce-all` option to check non-added
files as well
- #519 PR by @mshawcroft.
- #518 issue by @mshawcroft.
- `fix-byte-order-marker`: new hook which fixes UTF-8 byte-order marker.
- #522 PR by @jgowdy.
### Deprecations
- `check-byte-order-marker` is now deprecated for `fix-byte-order-marker`
3.2.0 - 2020-07-30
==================
### Features
- `debug-statements`: add support for `pydevd_pycharm` debugger
- #502 PR by @jgeerds.
### Fixes
- `check-executables-have-shebangs`: fix git-quoted files on windows (spaces,
non-ascii, etc.)
- #509 PR by @pawamoy.
- #508 issue by @pawamoy.
3.1.0 - 2020-05-20
==================

View file

@ -1,5 +1,5 @@
[![Build Status](https://asottile.visualstudio.com/asottile/_apis/build/status/pre-commit.pre-commit-hooks?branchName=master)](https://asottile.visualstudio.com/asottile/_build/latest?definitionId=17&branchName=master)
[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/17/master.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=17&branchName=master)
[![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)
[![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)
pre-commit-hooks
================
@ -15,7 +15,7 @@ Add this to your `.pre-commit-config.yaml`
```yaml
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0 # Use the ref you want to point at
rev: v6.0.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
# - id: ...
@ -26,8 +26,11 @@ Add this to your `.pre-commit-config.yaml`
#### `check-added-large-files`
Prevent giant files from being committed.
- Specify what is "too large" with `args: ['--maxkb=123']` (default=500kB).
- Limits checked files to those indicated as staged for addition by git.
- If `git-lfs` is installed, lfs files will be skipped
(requires `git-lfs>=2.2.1`)
- `--enforce-all` - Check all listed files not just those staged for
addition.
#### `check-ast`
Simply check whether files parse as valid python.
@ -39,23 +42,24 @@ Require literal syntax when initializing empty or zero Python builtin types.
- Ignore this requirement for specific builtin types with `--ignore=type1,type2,…`.
- Forbid `dict` keyword syntax with `--no-allow-dict-kwargs`.
#### `check-byte-order-marker`
Forbid files which have a UTF-8 byte-order marker
#### `check-case-conflict`
Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
#### `check-docstring-first`
Checks for a common error of placing code before the docstring.
#### `check-executables-have-shebangs`
Checks that non-binary executables have a proper shebang.
#### `check-illegal-windows-names`
Check for files that cannot be created on Windows.
#### `check-json`
Attempts to load all json files to verify syntax.
#### `check-merge-conflict`
Check for files that contain merge conflict strings.
- `--assume-in-merge` - Allows running the hook when there is no ongoing merge operation
#### `check-shebang-scripts-are-executable`
Checks that scripts with shebangs are executable.
#### `check-symlinks`
Checks for symlinks which do not point to anything.
@ -65,6 +69,10 @@ Attempts to load all TOML files to verify syntax.
#### `check-vcs-permalinks`
Ensures that links to vcs websites are permalinks.
- `--additional-github-domain DOMAIN` - Add check for specified domain.
Can be repeated multiple times. for example, if your company uses
GitHub Enterprise you may use something like
`--additional-github-domain github.example.com`
#### `check-xml`
Attempts to load all xml files to verify syntax.
@ -82,6 +90,12 @@ Attempts to load all yaml files to verify syntax.
#### `debug-statements`
Check for debugger imports and py37+ `breakpoint()` calls in python source.
#### `destroyed-symlinks`
Detects symlinks which are changed to regular files with a content of a path
which that symlink was pointing to.
This usually happens on Windows when a user clones a repository that has
symlinks but they do not have the permission to create symlinks.
#### `detect-aws-credentials`
Checks for the existence of AWS secrets that you have set up with the AWS CLI.
The following arguments are available:
@ -99,18 +113,28 @@ This hook replaces double quoted strings with single quoted strings.
#### `end-of-file-fixer`
Makes sure files end in a newline and only a newline.
#### `fix-encoding-pragma`
Add `# -*- coding: utf-8 -*-` to the top of python files.
- To remove the coding pragma pass `--remove` (useful in a python3-only codebase)
#### `file-contents-sorter`
Sort the lines in specified files (defaults to alphabetical).
You must provide list of target files as input to it.
You must provide the target [`files`](https://pre-commit.com/#config-files) as input.
Note that this hook WILL remove blank lines and does NOT respect any comments.
All newlines will be converted to line feeds (`\n`).
The following arguments are available:
- `--ignore-case` - fold lower case to upper case characters.
- `--unique` - ensure each line is unique.
#### `fix-byte-order-marker`
removes UTF-8 byte order marker
#### `forbid-new-submodules`
Prevent addition of new git submodules.
This is intended as a helper to migrate away from submodules. If you want to
ban them entirely use `forbid-submodules`
#### `forbid-submodules`
forbids any submodules in the repository.
#### `mixed-line-ending`
Replaces or checks mixed line ending.
- `--fix={auto,crlf,lf,no}`
@ -120,18 +144,27 @@ Replaces or checks mixed line ending.
- `no` - Checks if there is any mixed line ending without modifying any file.
#### `name-tests-test`
Assert that files in tests/ end in `_test.py`.
- Use `args: ['--django']` to match `test*.py` instead.
verifies that test files are named correctly.
- `--pytest` (the default): ensure tests match `.*_test\.py`
- `--pytest-test-first`: ensure tests match `test_.*\.py`
- `--django` / `--unittest`: ensure tests match `test.*\.py`
#### `no-commit-to-branch`
Protect specific branches from direct checkins.
- Use `args: [--branch, staging, --branch, master]` to set the branch.
`master` is the default if no branch argument is set.
- Use `args: [--branch, staging, --branch, main]` to set the branch.
Both `main` and `master` are protected by default if no branch argument is set.
- `-b` / `--branch` may be specified multiple times to protect multiple
branches.
- `-p` / `--pattern` can be used to protect branches that match a supplied regex
(e.g. `--pattern, release/.*`). May be specified multiple times.
Note that `no-commit-to-branch` is configured by default to [`always_run`](https://pre-commit.com/#config-always_run).
As a result, it will ignore any setting of [`files`](https://pre-commit.com/#config-files),
[`exclude`](https://pre-commit.com/#config-exclude), [`types`](https://pre-commit.com/#config-types)
or [`exclude_types`](https://pre-commit.com/#config-exclude_types).
Set [`always_run: false`](https://pre-commit.com/#config-always_run) to allow this hook to be skipped according to these
file filters. Caveat: In this configuration, empty commits (`git commit --allow-empty`) would always be allowed by this hook.
#### `pretty-format-json`
Checks that all your JSON files are pretty. "Pretty"
here means that keys are sorted and indented. You can configure this with
@ -143,14 +176,14 @@ the following commandline options:
- `--top-keys comma,separated,keys` - Keys to keep at the top of mappings.
#### `requirements-txt-fixer`
Sorts entries in requirements.txt and removes incorrect entry for `pkg-resources==0.0.0`
Sorts entries in requirements.txt and constraints.txt and removes incorrect entry for `pkg-resources==0.0.0`
#### `sort-simple-yaml`
Sorts simple YAML files which consist only of top-level
keys, preserving comments and blocks.
Note that `sort-simple-yaml` by default matches no `files` as it enforces a
very specific format. You must opt in to this by setting `files`, for example:
very specific format. You must opt in to this by setting [`files`](https://pre-commit.com/#config-files), for example:
```yaml
- id: sort-simple-yaml
@ -169,10 +202,10 @@ Trims trailing whitespace.
### Deprecated / replaced hooks
- `autopep8-wrapper`: instead use
[mirrors-autopep8](https://github.com/pre-commit/mirrors-autopep8)
- `pyflakes`: instead use `flake8`
- `flake8`: instead use [upstream flake8](https://gitlab.com/pycqa/flake8)
- `check-byte-order-marker`: instead use fix-byte-order-marker
- `fix-encoding-pragma`: instead use [`pyupgrade`](https://github.com/asottile/pyupgrade)
- `check-docstring-first`: fundamentally flawed, deprecated without replacement.
### As a standalone package

View file

@ -1,24 +0,0 @@
trigger:
branches:
include: [master, test-me-*]
tags:
include: ['*']
resources:
repositories:
- repository: asottile
type: github
endpoint: github
name: asottile/azure-pipeline-templates
ref: refs/tags/v1.0.0
jobs:
- template: job--pre-commit.yml@asottile
- template: job--python-tox.yml@asottile
parameters:
toxenvs: [py38]
os: windows
- template: job--python-tox.yml@asottile
parameters:
toxenvs: [pypy3, py36, py37, py38]
os: linux

View file

@ -1,32 +1,52 @@
from __future__ import annotations
import argparse
import json
import math
import os
from typing import Optional
from typing import Sequence
from typing import Set
import subprocess
from collections.abc import Sequence
from pre_commit_hooks.util import added_files
from pre_commit_hooks.util import CalledProcessError
from pre_commit_hooks.util import cmd_output
from pre_commit_hooks.util import zsplit
def lfs_files() -> Set[str]:
try:
# Introduced in git-lfs 2.2.0, first working in 2.2.1
lfs_ret = cmd_output('git', 'lfs', 'status', '--json')
except CalledProcessError: # pragma: no cover (with git-lfs)
lfs_ret = '{"files":{}}'
def filter_lfs_files(filenames: set[str]) -> None: # pragma: no cover (lfs)
"""Remove files tracked by git-lfs from the set."""
if not filenames:
return
return set(json.loads(lfs_ret)['files'])
check_attr = subprocess.run(
('git', 'check-attr', 'filter', '-z', '--stdin'),
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
encoding='utf-8',
check=True,
input='\0'.join(filenames),
)
stdout = zsplit(check_attr.stdout)
for i in range(0, len(stdout), 3):
filename, filter_tag = stdout[i], stdout[i + 2]
if filter_tag == 'lfs':
filenames.remove(filename)
def find_large_added_files(filenames: Sequence[str], maxkb: int) -> int:
def find_large_added_files(
filenames: Sequence[str],
maxkb: int,
*,
enforce_all: bool = False,
) -> int:
# Find all added files that are also in the list of files pre-commit tells
# us about
retv = 0
for filename in (added_files() & set(filenames)) - lfs_files():
kb = int(math.ceil(os.stat(filename).st_size / 1024))
filenames_filtered = set(filenames)
filter_lfs_files(filenames_filtered)
if not enforce_all:
filenames_filtered &= added_files()
for filename in filenames_filtered:
kb = math.ceil(os.stat(filename).st_size / 1024)
if kb > maxkb:
print(f'{filename} ({kb} KB) exceeds {maxkb} KB.')
retv = 1
@ -34,20 +54,28 @@ def find_large_added_files(filenames: Sequence[str], maxkb: int) -> int:
return retv
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'filenames', nargs='*',
help='Filenames pre-commit believes are changed.',
)
parser.add_argument(
'--maxkb', type=int, default=500,
help='Maxmimum allowable KB for added files',
'--enforce-all', action='store_true',
help='Enforce all files are checked, not just staged files.',
)
parser.add_argument(
'--maxkb', type=int, default=500,
help='Maximum allowable KB for added files',
)
args = parser.parse_args(argv)
return find_large_added_files(args.filenames, args.maxkb)
return find_large_added_files(
args.filenames,
args.maxkb,
enforce_all=args.enforce_all,
)
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,13 +1,14 @@
from __future__ import annotations
import argparse
import ast
import platform
import sys
import traceback
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
args = parser.parse_args(argv)
@ -29,4 +30,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,10 +1,9 @@
from __future__ import annotations
import argparse
import ast
from typing import List
from collections.abc import Sequence
from typing import NamedTuple
from typing import Optional
from typing import Sequence
from typing import Set
BUILTIN_TYPES = {
@ -27,38 +26,39 @@ class Call(NamedTuple):
class Visitor(ast.NodeVisitor):
def __init__(
self,
ignore: Optional[Sequence[str]] = None,
ignore: set[str],
allow_dict_kwargs: bool = True,
) -> None:
self.builtin_type_calls: List[Call] = []
self.ignore = set(ignore) if ignore else set()
self.builtin_type_calls: list[Call] = []
self.allow_dict_kwargs = allow_dict_kwargs
self._disallowed = BUILTIN_TYPES.keys() - ignore
def _check_dict_call(self, node: ast.Call) -> bool:
return self.allow_dict_kwargs and bool(node.keywords)
def visit_Call(self, node: ast.Call) -> None:
if not isinstance(node.func, ast.Name):
if (
# Ignore functions that are object attributes (`foo.bar()`).
# Assume that if the user calls `builtins.list()`, they know what
# they're doing.
return
if node.func.id not in set(BUILTIN_TYPES).difference(self.ignore):
return
if node.func.id == 'dict' and self._check_dict_call(node):
return
elif node.args:
return
self.builtin_type_calls.append(
Call(node.func.id, node.lineno, node.col_offset),
)
isinstance(node.func, ast.Name) and
node.func.id in self._disallowed and
(node.func.id != 'dict' or not self._check_dict_call(node)) and
not node.args
):
self.builtin_type_calls.append(
Call(node.func.id, node.lineno, node.col_offset),
)
self.generic_visit(node)
def check_file(
filename: str,
ignore: Optional[Sequence[str]] = None,
*,
ignore: set[str],
allow_dict_kwargs: bool = True,
) -> List[Call]:
) -> list[Call]:
with open(filename, 'rb') as f:
tree = ast.parse(f.read(), filename=filename)
visitor = Visitor(ignore=ignore, allow_dict_kwargs=allow_dict_kwargs)
@ -66,11 +66,11 @@ def check_file(
return visitor.builtin_type_calls
def parse_ignore(value: str) -> Set[str]:
def parse_ignore(value: str) -> set[str]:
return set(value.split(','))
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
parser.add_argument('--ignore', type=parse_ignore, default=set())
@ -103,4 +103,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,23 +0,0 @@
import argparse
from typing import Optional
from typing import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check')
args = parser.parse_args(argv)
retv = 0
for filename in args.filenames:
with open(filename, 'rb') as f:
if f.read(3) == b'\xef\xbb\xbf':
retv = 1
print(f'{filename}: Has a byte-order marker')
return retv
if __name__ == '__main__':
exit(main())

View file

@ -1,20 +1,35 @@
from __future__ import annotations
import argparse
from typing import Iterable
from typing import Optional
from typing import Sequence
from typing import Set
from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence
from pre_commit_hooks.util import added_files
from pre_commit_hooks.util import cmd_output
def lower_set(iterable: Iterable[str]) -> Set[str]:
def lower_set(iterable: Iterable[str]) -> set[str]:
return {x.lower() for x in iterable}
def parents(file: str) -> Iterator[str]:
path_parts = file.split('/')
path_parts.pop()
while path_parts:
yield '/'.join(path_parts)
path_parts.pop()
def directories_for(files: set[str]) -> set[str]:
return {parent for file in files for parent in parents(file)}
def find_conflicting_filenames(filenames: Sequence[str]) -> int:
repo_files = set(cmd_output('git', 'ls-files').splitlines())
repo_files |= directories_for(repo_files)
relevant_files = set(filenames) | added_files()
relevant_files |= directories_for(relevant_files)
repo_files -= relevant_files
retv = 0
@ -41,7 +56,7 @@ def find_conflicting_filenames(filenames: Sequence[str]) -> int:
return retv
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'filenames', nargs='*',
@ -54,4 +69,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,9 +1,10 @@
from __future__ import annotations
import argparse
import io
import tokenize
from collections.abc import Sequence
from tokenize import tokenize as tokenize_tokenize
from typing import Optional
from typing import Sequence
NON_CODE_TOKENS = frozenset((
tokenize.COMMENT, tokenize.ENDMARKER, tokenize.NEWLINE, tokenize.NL,
@ -27,13 +28,13 @@ def check_docstring_first(src: bytes, filename: str = '<unknown>') -> int:
if tok_type == tokenize.STRING and scol == 0:
if found_docstring_line is not None:
print(
f'{filename}:{sline} Multiple module docstrings '
f'{filename}:{sline}: Multiple module docstrings '
f'(first docstring on line {found_docstring_line}).',
)
return 1
elif found_code_line is not None:
print(
f'{filename}:{sline} Module docstring appears after code '
f'{filename}:{sline}: Module docstring appears after code '
f'(code seen on line {found_code_line}).',
)
return 1
@ -45,7 +46,7 @@ def check_docstring_first(src: bytes, filename: str = '<unknown>') -> int:
return 0
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
args = parser.parse_args(argv)

View file

@ -1,47 +1,60 @@
"""Check that executable text files have a shebang."""
from __future__ import annotations
import argparse
import shlex
import sys
from typing import List
from typing import Optional
from typing import Sequence
from typing import Set
from collections.abc import Generator
from collections.abc import Sequence
from typing import NamedTuple
from pre_commit_hooks.util import cmd_output
from pre_commit_hooks.util import zsplit
EXECUTABLE_VALUES = frozenset(('1', '3', '5', '7'))
def check_executables(paths: List[str]) -> int:
if sys.platform == 'win32': # pragma: win32 cover
def check_executables(paths: list[str]) -> int:
fs_tracks_executable_bit = cmd_output(
'git', 'config', 'core.fileMode', retcode=None,
).strip()
if fs_tracks_executable_bit == 'false': # pragma: win32 cover
return _check_git_filemode(paths)
else: # pragma: win32 no cover
retv = 0
for path in paths:
if not _check_has_shebang(path):
if not has_shebang(path):
_message(path)
retv = 1
return retv
def _check_git_filemode(paths: Sequence[str]) -> int:
outs = cmd_output('git', 'ls-files', '--stage', '--', *paths)
seen: Set[str] = set()
for out in outs.splitlines():
metadata, path = out.split('\t')
tagmode = metadata.split(' ', 1)[0]
class GitLsFile(NamedTuple):
mode: str
filename: str
is_executable = any(b in EXECUTABLE_VALUES for b in tagmode[-3:])
has_shebang = _check_has_shebang(path)
if is_executable and not has_shebang:
_message(path)
seen.add(path)
def git_ls_files(paths: Sequence[str]) -> Generator[GitLsFile]:
outs = cmd_output('git', 'ls-files', '-z', '--stage', '--', *paths)
for out in zsplit(outs):
metadata, filename = out.split('\t')
mode, _, _ = metadata.split()
yield GitLsFile(mode, filename)
def _check_git_filemode(paths: Sequence[str]) -> int:
seen: set[str] = set()
for ls_file in git_ls_files(paths):
is_executable = any(b in EXECUTABLE_VALUES for b in ls_file.mode[-3:])
if is_executable and not has_shebang(ls_file.filename):
_message(ls_file.filename)
seen.add(ls_file.filename)
return int(bool(seen))
def _check_has_shebang(path: str) -> int:
def has_shebang(path: str) -> int:
with open(path, 'rb') as f:
first_bytes = f.read(2)
@ -53,12 +66,14 @@ def _message(path: str) -> None:
f'{path}: marked executable but has no (or invalid) shebang!\n'
f" If it isn't supposed to be executable, try: "
f'`chmod -x {shlex.quote(path)}`\n'
f' If on Windows, you may also need to: '
f'`git add --chmod=-x {shlex.quote(path)}`\n'
f' If it is supposed to be executable, double-check its shebang.',
file=sys.stderr,
)
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('filenames', nargs='*')
args = parser.parse_args(argv)
@ -67,4 +82,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,10 +1,24 @@
from __future__ import annotations
import argparse
import json
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
from typing import Any
def main(argv: Optional[Sequence[str]] = None) -> int:
def raise_duplicate_keys(
ordered_pairs: list[tuple[str, Any]],
) -> dict[str, Any]:
d = {}
for key, val in ordered_pairs:
if key in d:
raise ValueError(f'Duplicate key: {key}')
else:
d[key] = val
return d
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)
@ -13,7 +27,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
for filename in args.filenames:
with open(filename, 'rb') as f:
try:
json.load(f)
json.load(f, object_pairs_hook=raise_duplicate_keys)
except ValueError as exc:
print(f'{filename}: Failed to json decode ({exc})')
retval = 1
@ -21,4 +35,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,29 +1,34 @@
from __future__ import annotations
import argparse
import os.path
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
from pre_commit_hooks.util import cmd_output
CONFLICT_PATTERNS = [
b'<<<<<<< ',
b'======= ',
b'=======\r\n',
b'=======\n',
b'>>>>>>> ',
]
def is_in_merge() -> int:
def is_in_merge() -> bool:
git_dir = cmd_output('git', 'rev-parse', '--git-dir').rstrip()
return (
os.path.exists(os.path.join('.git', 'MERGE_MSG')) and
os.path.exists(os.path.join(git_dir, 'MERGE_MSG')) and
(
os.path.exists(os.path.join('.git', 'MERGE_HEAD')) or
os.path.exists(os.path.join('.git', 'rebase-apply')) or
os.path.exists(os.path.join('.git', 'rebase-merge'))
os.path.exists(os.path.join(git_dir, 'MERGE_HEAD')) or
os.path.exists(os.path.join(git_dir, 'rebase-apply')) or
os.path.exists(os.path.join(git_dir, 'rebase-merge'))
)
)
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
parser.add_argument('--assume-in-merge', action='store_true')
@ -35,12 +40,12 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
retcode = 0
for filename in args.filenames:
with open(filename, 'rb') as inputfile:
for i, line in enumerate(inputfile):
for i, line in enumerate(inputfile, start=1):
for pattern in CONFLICT_PATTERNS:
if line.startswith(pattern):
print(
f'Merge conflict string "{pattern.decode()}" '
f'found in {filename}:{i + 1}',
f'{filename}:{i}: Merge conflict string '
f'{pattern.strip().decode()!r} found',
)
retcode = 1
@ -48,4 +53,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -0,0 +1,54 @@
"""Check that text files with a shebang are executable."""
from __future__ import annotations
import argparse
import shlex
import sys
from collections.abc import Sequence
from pre_commit_hooks.check_executables_have_shebangs import EXECUTABLE_VALUES
from pre_commit_hooks.check_executables_have_shebangs import git_ls_files
from pre_commit_hooks.check_executables_have_shebangs import has_shebang
def check_shebangs(paths: list[str]) -> int:
# Cannot optimize on non-executability here if we intend this check to
# work on win32 -- and that's where problems caused by non-executability
# (elsewhere) are most likely to arise from.
return _check_git_filemode(paths)
def _check_git_filemode(paths: Sequence[str]) -> int:
seen: set[str] = set()
for ls_file in git_ls_files(paths):
is_executable = any(b in EXECUTABLE_VALUES for b in ls_file.mode[-3:])
if not is_executable and has_shebang(ls_file.filename):
_message(ls_file.filename)
seen.add(ls_file.filename)
return int(bool(seen))
def _message(path: str) -> None:
print(
f'{path}: has a shebang but is not marked executable!\n'
f' If it is supposed to be executable, try: '
f'`chmod +x {shlex.quote(path)}`\n'
f' If on Windows, you may also need to: '
f'`git add --chmod=+x {shlex.quote(path)}`\n'
f' If it is not supposed to be executable, double-check its shebang '
f'is wanted.\n',
file=sys.stderr,
)
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('filenames', nargs='*')
args = parser.parse_args(argv)
return check_shebangs(args.filenames)
if __name__ == '__main__':
raise SystemExit(main())

View file

@ -1,10 +1,11 @@
from __future__ import annotations
import argparse
import os.path
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser(description='Checks for broken symlinks.')
parser.add_argument('filenames', nargs='*', help='Filenames to check')
args = parser.parse_args(argv)
@ -23,4 +24,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,11 +1,16 @@
from __future__ import annotations
import argparse
from typing import Optional
from typing import Sequence
import sys
from collections.abc import Sequence
import toml
if sys.version_info >= (3, 11): # pragma: >=3.11 cover
import tomllib
else: # pragma: <3.11 cover
import tomli as tomllib
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)
@ -13,12 +18,13 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
retval = 0
for filename in args.filenames:
try:
toml.load(filename)
except toml.TomlDecodeError as exc:
with open(filename, mode='rb') as fp:
tomllib.load(fp)
except tomllib.TOMLDecodeError as exc:
print(f'{filename}: {exc}')
retval = 1
return retval
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,35 +1,53 @@
from __future__ import annotations
import argparse
import re
import sys
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
from re import Pattern
GITHUB_NON_PERMALINK = re.compile(
br'https://github.com/[^/ ]+/[^/ ]+/blob/master/[^# ]+#L\d+',
)
def _get_pattern(domain: str) -> Pattern[bytes]:
regex = (
rf'https://{domain}/[^/ ]+/[^/ ]+/blob/'
r'(?![a-fA-F0-9]{4,64}/)([^/. ]+)/[^# ]+#L\d+'
)
return re.compile(regex.encode())
def _check_filename(filename: str) -> int:
def _check_filename(filename: str, patterns: list[Pattern[bytes]]) -> int:
retv = 0
with open(filename, 'rb') as f:
for i, line in enumerate(f, 1):
if GITHUB_NON_PERMALINK.search(line):
sys.stdout.write(f'{filename}:{i}:')
sys.stdout.flush()
sys.stdout.buffer.write(line)
retv = 1
for pattern in patterns:
if pattern.search(line):
sys.stdout.write(f'{filename}:{i}:')
sys.stdout.flush()
sys.stdout.buffer.write(line)
retv = 1
return retv
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
parser.add_argument(
'--additional-github-domain',
dest='additional_github_domains',
action='append',
default=['github.com'],
)
args = parser.parse_args(argv)
patterns = [
_get_pattern(domain)
for domain in args.additional_github_domains
]
retv = 0
for filename in args.filenames:
retv |= _check_filename(filename)
retv |= _check_filename(filename, patterns)
if retv:
print()
@ -39,4 +57,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,10 +1,11 @@
from __future__ import annotations
import argparse
import xml.sax.handler
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='XML filenames to check.')
args = parser.parse_args(argv)
@ -22,4 +23,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,16 +1,17 @@
from __future__ import annotations
import argparse
from collections.abc import Generator
from collections.abc import Sequence
from typing import Any
from typing import Generator
from typing import NamedTuple
from typing import Optional
from typing import Sequence
import ruamel.yaml
yaml = ruamel.yaml.YAML(typ='safe')
def _exhaust(gen: Generator[str, None, None]) -> None:
def _exhaust(gen: Generator[str]) -> None:
for _ in gen:
pass
@ -36,7 +37,7 @@ LOAD_FNS = {
}
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'-m', '--multi', '--allow-multiple-documents', action='store_true',
@ -45,7 +46,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
'--unsafe', action='store_true',
help=(
'Instead of loading the files, simply parse them for syntax. '
'A syntax-only check enables extensions and unsafe contstructs '
'A syntax-only check enables extensions and unsafe constructs '
'which would otherwise be forbidden. Using this option removes '
'all guarantees of portability to other yaml implementations. '
'Implies --allow-multiple-documents'
@ -68,4 +69,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,13 +1,24 @@
from __future__ import annotations
import argparse
import ast
import traceback
from typing import List
from collections.abc import Sequence
from typing import NamedTuple
from typing import Optional
from typing import Sequence
DEBUG_STATEMENTS = {'pdb', 'ipdb', 'pudb', 'q', 'rdb', 'rpdb', 'wdb'}
DEBUG_STATEMENTS = {
'bpdb',
'ipdb',
'pdb',
'pdbr',
'pudb',
'pydevd_pycharm',
'q',
'rdb',
'rpdb',
'wdb',
}
class Debug(NamedTuple):
@ -19,7 +30,7 @@ class Debug(NamedTuple):
class DebugStatementParser(ast.NodeVisitor):
def __init__(self) -> None:
self.breakpoints: List[Debug] = []
self.breakpoints: list[Debug] = []
def visit_Import(self, node: ast.Import) -> None:
for name in node.names:
@ -55,12 +66,12 @@ def check_file(filename: str) -> int:
visitor.visit(ast_obj)
for bp in visitor.breakpoints:
print(f'{filename}:{bp.line}:{bp.col} - {bp.name} {bp.reason}')
print(f'{filename}:{bp.line}:{bp.col}: {bp.name} {bp.reason}')
return int(bool(visitor.breakpoints))
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to run')
args = parser.parse_args(argv)
@ -72,4 +83,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -0,0 +1,92 @@
from __future__ import annotations
import argparse
import shlex
import subprocess
from collections.abc import Sequence
from pre_commit_hooks.util import cmd_output
from pre_commit_hooks.util import zsplit
ORDINARY_CHANGED_ENTRIES_MARKER = '1'
PERMS_LINK = '120000'
PERMS_NONEXIST = '000000'
def find_destroyed_symlinks(files: Sequence[str]) -> list[str]:
destroyed_links: list[str] = []
if not files:
return destroyed_links
for line in zsplit(
cmd_output('git', 'status', '--porcelain=v2', '-z', '--', *files),
):
splitted = line.split(' ')
if splitted and splitted[0] == ORDINARY_CHANGED_ENTRIES_MARKER:
# https://git-scm.com/docs/git-status#_changed_tracked_entries
(
_, _, _,
mode_HEAD,
mode_index,
_,
hash_HEAD,
hash_index,
*path_splitted,
) = splitted
path = ' '.join(path_splitted)
if (
mode_HEAD == PERMS_LINK and
mode_index != PERMS_LINK and
mode_index != PERMS_NONEXIST
):
if hash_HEAD == hash_index:
# if old and new hashes are equal, it's not needed to check
# anything more, we've found a destroyed symlink for sure
destroyed_links.append(path)
else:
# if old and new hashes are *not* equal, it doesn't mean
# that everything is OK - new file may be altered
# by something like trailing-whitespace and/or
# mixed-line-ending hooks so we need to go deeper
SIZE_CMD = ('git', 'cat-file', '-s')
size_index = int(cmd_output(*SIZE_CMD, hash_index).strip())
size_HEAD = int(cmd_output(*SIZE_CMD, hash_HEAD).strip())
# in the worst case new file may have CRLF added
# so check content only if new file is bigger
# not more than 2 bytes compared to the old one
if size_index <= size_HEAD + 2:
head_content = subprocess.check_output(
('git', 'cat-file', '-p', hash_HEAD),
).rstrip()
index_content = subprocess.check_output(
('git', 'cat-file', '-p', hash_index),
).rstrip()
if head_content == index_content:
destroyed_links.append(path)
return destroyed_links
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)
destroyed_links = find_destroyed_symlinks(files=args.filenames)
if destroyed_links:
print('Destroyed symlinks:')
for destroyed_link in destroyed_links:
print(f'- {destroyed_link}')
print('You should unstage affected files:')
print(f'\tgit reset HEAD -- {shlex.join(destroyed_links)}')
print(
'And retry commit. As a long term solution '
'you may try to explicitly tell git that your '
'environment does not support symlinks:',
)
print('\tgit config core.symlinks false')
return 1
else:
return 0
if __name__ == '__main__':
raise SystemExit(main())

View file

@ -1,11 +1,10 @@
from __future__ import annotations
import argparse
import configparser
import os
from typing import List
from collections.abc import Sequence
from typing import NamedTuple
from typing import Optional
from typing import Sequence
from typing import Set
class BadFile(NamedTuple):
@ -13,7 +12,7 @@ class BadFile(NamedTuple):
key: str
def get_aws_cred_files_from_env() -> Set[str]:
def get_aws_cred_files_from_env() -> set[str]:
"""Extract credential file paths from environment variables."""
return {
os.environ[env_var]
@ -25,7 +24,7 @@ def get_aws_cred_files_from_env() -> Set[str]:
}
def get_aws_secrets_from_env() -> Set[str]:
def get_aws_secrets_from_env() -> set[str]:
"""Extract AWS secrets from environment variables."""
keys = set()
for env_var in (
@ -36,7 +35,7 @@ def get_aws_secrets_from_env() -> Set[str]:
return keys
def get_aws_secrets_from_file(credentials_file: str) -> Set[str]:
def get_aws_secrets_from_file(credentials_file: str) -> set[str]:
"""Extract AWS secrets from configuration files.
Read an ini-style configuration file and return a set with all found AWS
@ -69,8 +68,8 @@ def get_aws_secrets_from_file(credentials_file: str) -> Set[str]:
def check_file_for_aws_keys(
filenames: Sequence[str],
keys: Set[bytes],
) -> List[BadFile]:
keys: set[bytes],
) -> list[BadFile]:
"""Check if files contain AWS secrets.
Return a list of all files containing AWS secrets and keys found, with all
@ -90,7 +89,7 @@ def check_file_for_aws_keys(
return bad_files
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='+', help='Filenames to run')
parser.add_argument(
@ -119,7 +118,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
# of files to to gather AWS secrets from.
credential_files |= get_aws_cred_files_from_env()
keys: Set[str] = set()
keys: set[str] = set()
for credential_file in credential_files:
keys |= get_aws_secrets_from_file(credential_file)
@ -149,4 +148,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,6 +1,7 @@
from __future__ import annotations
import argparse
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
BLACKLIST = [
b'BEGIN RSA PRIVATE KEY',
@ -11,10 +12,12 @@ BLACKLIST = [
b'PuTTY-User-Key-File-2',
b'BEGIN SSH2 ENCRYPTED PRIVATE KEY',
b'BEGIN PGP PRIVATE KEY BLOCK',
b'BEGIN ENCRYPTED PRIVATE KEY',
b'BEGIN OpenVPN Static key V1',
]
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check')
args = parser.parse_args(argv)
@ -36,4 +39,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,8 +1,9 @@
from __future__ import annotations
import argparse
import os
from collections.abc import Sequence
from typing import IO
from typing import Optional
from typing import Sequence
def fix_file(file_obj: IO[bytes]) -> int:
@ -48,7 +49,7 @@ def fix_file(file_obj: IO[bytes]) -> int:
return 0
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
args = parser.parse_args(argv)
@ -67,4 +68,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -2,28 +2,45 @@
A very simple pre-commit hook that, when passed one or more filenames
as arguments, will sort the lines in those files.
An example use case for this: you have a deploy-whitelist.txt file
An example use case for this: you have a deploy-allowlist.txt file
in a repo that contains a list of filenames that is used to specify
files to be included in a docker container. This file has one filename
per line. Various users are adding/removing lines from this file; using
this hook on that file should reduce the instances of git merge
conflicts and keep the file nicely ordered.
"""
from __future__ import annotations
import argparse
from collections.abc import Callable
from collections.abc import Iterable
from collections.abc import Sequence
from typing import Any
from typing import IO
from typing import Optional
from typing import Sequence
PASS = 0
FAIL = 1
def sort_file_contents(f: IO[bytes]) -> int:
def sort_file_contents(
f: IO[bytes],
key: Callable[[bytes], Any] | None,
*,
unique: bool = False,
) -> int:
before = list(f)
after = sorted(line.strip(b'\n\r') for line in before if line.strip())
lines: Iterable[bytes] = (
line.rstrip(b'\n\r') for line in before if line.strip()
)
if unique:
lines = set(lines)
after = sorted(lines, key=key)
before_string = b''.join(before)
after_string = b'\n'.join(after) + b'\n'
after_string = b'\n'.join(after)
if after_string:
after_string += b'\n'
if before_string == after_string:
return PASS
@ -34,16 +51,33 @@ def sort_file_contents(f: IO[bytes]) -> int:
return FAIL
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='+', help='Files to sort')
mutex = parser.add_mutually_exclusive_group(required=False)
mutex.add_argument(
'--ignore-case',
action='store_const',
const=bytes.lower,
default=None,
help='fold lower case to upper case characters',
)
mutex.add_argument(
'--unique',
action='store_true',
help='ensure each line is unique',
)
args = parser.parse_args(argv)
retv = PASS
for arg in args.filenames:
with open(arg, 'rb+') as file_obj:
ret_for_file = sort_file_contents(file_obj)
ret_for_file = sort_file_contents(
file_obj, key=args.ignore_case, unique=args.unique,
)
if ret_for_file:
print(f'Sorting {arg}')
@ -54,4 +88,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -0,0 +1,31 @@
from __future__ import annotations
import argparse
from collections.abc import Sequence
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check')
args = parser.parse_args(argv)
retv = 0
for filename in args.filenames:
with open(filename, 'rb') as f_b:
bts = f_b.read(3)
if bts == b'\xef\xbb\xbf':
with open(filename, newline='', encoding='utf-8-sig') as f:
contents = f.read()
with open(filename, 'w', newline='', encoding='utf-8') as f:
f.write(contents)
print(f'{filename}: removed byte-order marker')
retv = 1
return retv
if __name__ == '__main__':
raise SystemExit(main())

View file

@ -1,148 +0,0 @@
import argparse
from typing import IO
from typing import NamedTuple
from typing import Optional
from typing import Sequence
DEFAULT_PRAGMA = b'# -*- coding: utf-8 -*-'
def has_coding(line: bytes) -> bool:
if not line.strip():
return False
return (
line.lstrip()[:1] == b'#' and (
b'unicode' in line or
b'encoding' in line or
b'coding:' in line or
b'coding=' in line
)
)
class ExpectedContents(NamedTuple):
shebang: bytes
rest: bytes
# True: has exactly the coding pragma expected
# False: missing coding pragma entirely
# None: has a coding pragma, but it does not match
pragma_status: Optional[bool]
ending: bytes
@property
def has_any_pragma(self) -> bool:
return self.pragma_status is not False
def is_expected_pragma(self, remove: bool) -> bool:
expected_pragma_status = not remove
return self.pragma_status is expected_pragma_status
def _get_expected_contents(
first_line: bytes,
second_line: bytes,
rest: bytes,
expected_pragma: bytes,
) -> ExpectedContents:
ending = b'\r\n' if first_line.endswith(b'\r\n') else b'\n'
if first_line.startswith(b'#!'):
shebang = first_line
potential_coding = second_line
else:
shebang = b''
potential_coding = first_line
rest = second_line + rest
if potential_coding.rstrip(b'\r\n') == expected_pragma:
pragma_status: Optional[bool] = True
elif has_coding(potential_coding):
pragma_status = None
else:
pragma_status = False
rest = potential_coding + rest
return ExpectedContents(
shebang=shebang, rest=rest, pragma_status=pragma_status, ending=ending,
)
def fix_encoding_pragma(
f: IO[bytes],
remove: bool = False,
expected_pragma: bytes = DEFAULT_PRAGMA,
) -> int:
expected = _get_expected_contents(
f.readline(), f.readline(), f.read(), expected_pragma,
)
# Special cases for empty files
if not expected.rest.strip():
# If a file only has a shebang or a coding pragma, remove it
if expected.has_any_pragma or expected.shebang:
f.seek(0)
f.truncate()
f.write(b'')
return 1
else:
return 0
if expected.is_expected_pragma(remove):
return 0
# Otherwise, write out the new file
f.seek(0)
f.truncate()
f.write(expected.shebang)
if not remove:
f.write(expected_pragma + expected.ending)
f.write(expected.rest)
return 1
def _normalize_pragma(pragma: str) -> bytes:
return pragma.encode().rstrip()
def main(argv: Optional[Sequence[str]] = None) -> int:
parser = argparse.ArgumentParser(
'Fixes the encoding pragma of python files',
)
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
parser.add_argument(
'--pragma', default=DEFAULT_PRAGMA, type=_normalize_pragma,
help=(
f'The encoding pragma to use. '
f'Default: {DEFAULT_PRAGMA.decode()}'
),
)
parser.add_argument(
'--remove', action='store_true',
help='Remove the encoding pragma (Useful in a python3-only codebase)',
)
args = parser.parse_args(argv)
retv = 0
if args.remove:
fmt = 'Removed encoding pragma from {filename}'
else:
fmt = 'Added `{pragma}` to {filename}'
for filename in args.filenames:
with open(filename, 'r+b') as f:
file_ret = fix_encoding_pragma(
f, remove=args.remove, expected_pragma=args.pragma,
)
retv |= file_ret
if file_ret:
print(
fmt.format(pragma=args.pragma.decode(), filename=filename),
)
return retv
if __name__ == '__main__':
exit(main())

View file

@ -1,14 +1,30 @@
from typing import Optional
from typing import Sequence
from __future__ import annotations
import argparse
import os
from collections.abc import Sequence
from pre_commit_hooks.util import cmd_output
def main(argv: Optional[Sequence[str]] = None) -> int:
# `argv` is ignored, pre-commit will send us a list of files that we
# don't care about
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
args = parser.parse_args(argv)
if (
'PRE_COMMIT_FROM_REF' in os.environ and
'PRE_COMMIT_TO_REF' in os.environ
):
diff_arg = '...'.join((
os.environ['PRE_COMMIT_FROM_REF'],
os.environ['PRE_COMMIT_TO_REF'],
))
else:
diff_arg = '--staged'
added_diff = cmd_output(
'git', 'diff', '--staged', '--diff-filter=A', '--raw',
'git', 'diff', '--diff-filter=A', '--raw', diff_arg, '--',
*args.filenames,
)
retv = 0
for line in added_diff.splitlines():
@ -29,4 +45,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,8 +1,8 @@
from __future__ import annotations
import argparse
import collections
from typing import Dict
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
CRLF = b'\r\n'
@ -25,7 +25,7 @@ def fix_filename(filename: str, fix: str) -> int:
with open(filename, 'rb') as f:
contents = f.read()
counts: Dict[bytes, int] = collections.defaultdict(int)
counts: dict[bytes, int] = collections.defaultdict(int)
for line in contents.splitlines(True):
for ending in ALL_ENDINGS:
@ -62,7 +62,7 @@ def fix_filename(filename: str, fix: str) -> int:
return other_endings
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'-f', '--fix',
@ -85,4 +85,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,8 +1,9 @@
from __future__ import annotations
import argparse
import re
from collections.abc import Sequence
from typing import AbstractSet
from typing import Optional
from typing import Sequence
from pre_commit_hooks.util import CalledProcessError
from pre_commit_hooks.util import cmd_output
@ -23,7 +24,7 @@ def is_on_branch(
)
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'-b', '--branch', action='append',
@ -38,10 +39,10 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
)
args = parser.parse_args(argv)
protected = frozenset(args.branch or ('master',))
protected = frozenset(args.branch or ('master', 'main'))
patterns = frozenset(args.pattern or ())
return int(is_on_branch(protected, patterns))
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,12 +1,11 @@
from __future__ import annotations
import argparse
import json
import sys
from collections.abc import Mapping
from collections.abc import Sequence
from difflib import unified_diff
from typing import List
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import Union
def _get_pretty_format(
@ -16,7 +15,7 @@ def _get_pretty_format(
sort_keys: bool = True,
top_keys: Sequence[str] = (),
) -> str:
def pairs_first(pairs: Sequence[Tuple[str, str]]) -> Mapping[str, str]:
def pairs_first(pairs: Sequence[tuple[str, str]]) -> Mapping[str, str]:
before = [pair for pair in pairs if pair[0] in top_keys]
before = sorted(before, key=lambda x: top_keys.index(x[0]))
after = [pair for pair in pairs if pair[0] not in top_keys]
@ -37,7 +36,7 @@ def _autofix(filename: str, new_contents: str) -> None:
f.write(new_contents)
def parse_num_to_int(s: str) -> Union[int, str]:
def parse_num_to_int(s: str) -> int | str:
"""Convert string numbers to int, leaving strings as is."""
try:
return int(s)
@ -45,7 +44,7 @@ def parse_num_to_int(s: str) -> Union[int, str]:
return s
def parse_topkeys(s: str) -> List[str]:
def parse_topkeys(s: str) -> list[str]:
return s.split(',')
@ -56,7 +55,7 @@ def get_diff(source: str, target: str, file: str) -> str:
return ''.join(diff)
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'--autofix',
@ -111,26 +110,28 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
contents, args.indent, ensure_ascii=not args.no_ensure_ascii,
sort_keys=not args.no_sort_keys, top_keys=args.top_keys,
)
if contents != pretty_contents:
if args.autofix:
_autofix(json_file, pretty_contents)
else:
print(
get_diff(contents, pretty_contents, json_file),
end='',
)
status = 1
except ValueError:
print(
f'Input File {json_file} is not a valid JSON, consider using '
f'check-json',
)
return 1
status = 1
else:
if contents != pretty_contents:
if args.autofix:
_autofix(json_file, pretty_contents)
else:
diff_output = get_diff(
contents,
pretty_contents,
json_file,
)
sys.stdout.buffer.write(diff_output.encode())
status = 1
return status
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,9 +1,10 @@
from __future__ import annotations
import sys
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
argv = argv if argv is not None else sys.argv[1:]
hookid, new_hookid, url = argv[:3]
raise SystemExit(
@ -12,4 +13,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,9 +1,9 @@
from __future__ import annotations
import argparse
import re
from collections.abc import Sequence
from typing import IO
from typing import List
from typing import Optional
from typing import Sequence
PASS = 0
@ -15,8 +15,8 @@ class Requirement:
UNTIL_SEP = re.compile(rb'[^;\s]+')
def __init__(self) -> None:
self.value: Optional[bytes] = None
self.comments: List[bytes] = []
self.value: bytes | None = None
self.comments: list[bytes] = []
@property
def name(self) -> bytes:
@ -36,7 +36,7 @@ class Requirement:
return name[:m.start()]
def __lt__(self, requirement: 'Requirement') -> int:
def __lt__(self, requirement: Requirement) -> bool:
# \n means top of file comment, so always return True,
# otherwise just do a string comparison with value.
assert self.value is not None, self.value
@ -45,6 +45,11 @@ class Requirement:
elif requirement.value == b'\n':
return False
else:
# if 2 requirements have the same name, the one with comments
# needs to go first (so that when removing duplicates, the one
# with comments is kept)
if self.name == requirement.name:
return bool(self.comments) > bool(requirement.comments)
return self.name < requirement.name
def is_complete(self) -> bool:
@ -61,9 +66,9 @@ class Requirement:
def fix_requirements(f: IO[bytes]) -> int:
requirements: List[Requirement] = []
requirements: list[Requirement] = []
before = list(f)
after: List[bytes] = []
after: list[bytes] = []
before_string = b''.join(before)
@ -95,7 +100,7 @@ def fix_requirements(f: IO[bytes]) -> int:
requirement.value = b'\n'
else:
requirement.comments.append(line)
elif line.startswith(b'#') or line.strip() == b'':
elif line.lstrip().startswith(b'#') or line.strip() == b'':
requirement.comments.append(line)
else:
requirement.append_value(line)
@ -110,13 +115,20 @@ def fix_requirements(f: IO[bytes]) -> int:
# which is automatically added by broken pip package under Debian
requirements = [
req for req in requirements
if req.value != b'pkg-resources==0.0.0\n'
if req.value not in [
b'pkg-resources==0.0.0\n',
b'pkg_resources==0.0.0\n',
]
]
# sort the requirements and remove duplicates
prev = None
for requirement in sorted(requirements):
after.extend(requirement.comments)
assert requirement.value, requirement.value
after.append(requirement.value)
if prev is None or requirement.value != prev.value:
after.append(requirement.value)
prev = requirement
after.extend(rest)
after_string = b''.join(after)
@ -130,7 +142,7 @@ def fix_requirements(f: IO[bytes]) -> int:
return FAIL
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
args = parser.parse_args(argv)
@ -150,4 +162,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

19
pre_commit_hooks/sort_simple_yaml.py Executable file → Normal file
View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
"""Sort a simple YAML file, keeping blocks of comments and definitions
together.
@ -18,16 +17,16 @@ We assume a strict subset of YAML that looks like:
In other words, we don't sort deeper than the top layer, and might corrupt
complicated YAML files.
"""
from __future__ import annotations
import argparse
from typing import List
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
QUOTES = ["'", '"']
def sort(lines: List[str]) -> List[str]:
def sort(lines: list[str]) -> list[str]:
"""Sort a YAML file in alphabetical order, keeping blocks together.
:param lines: array of strings (without newlines)
@ -45,7 +44,7 @@ def sort(lines: List[str]) -> List[str]:
return new_lines
def parse_block(lines: List[str], header: bool = False) -> List[str]:
def parse_block(lines: list[str], header: bool = False) -> list[str]:
"""Parse and return a single block, popping off the start of `lines`.
If parsing a header block, we stop after we reach a line that is not a
@ -61,7 +60,7 @@ def parse_block(lines: List[str], header: bool = False) -> List[str]:
return block_lines
def parse_blocks(lines: List[str]) -> List[List[str]]:
def parse_blocks(lines: list[str]) -> list[list[str]]:
"""Parse and return all possible blocks, popping off the start of `lines`.
:param lines: list of lines
@ -78,7 +77,7 @@ def parse_blocks(lines: List[str]) -> List[List[str]]:
return blocks
def first_key(lines: List[str]) -> str:
def first_key(lines: list[str]) -> str:
"""Returns a string representing the sort key of a block.
The sort key is the first YAML key we encounter, ignoring comments, and
@ -100,7 +99,7 @@ def first_key(lines: List[str]) -> str:
return '' # not actually reached in reality
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
args = parser.parse_args(argv)
@ -123,4 +122,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,10 +1,17 @@
from __future__ import annotations
import argparse
import io
import re
import sys
import tokenize
from typing import List
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
if sys.version_info >= (3, 12): # pragma: >=3.12 cover
FSTRING_START = tokenize.FSTRING_START
FSTRING_END = tokenize.FSTRING_END
else: # pragma: <3.12 cover
FSTRING_START = FSTRING_END = -1
START_QUOTE_RE = re.compile('^[a-zA-Z]*"')
@ -24,7 +31,7 @@ def handle_match(token_text: str) -> str:
return token_text
def get_line_offsets_by_line_no(src: str) -> List[int]:
def get_line_offsets_by_line_no(src: str) -> list[int]:
# Padded so we can index with line number
offsets = [-1, 0]
for line in src.splitlines(True):
@ -40,11 +47,17 @@ def fix_strings(filename: str) -> int:
# Basically a mutable string
splitcontents = list(contents)
fstring_depth = 0
# Iterate in reverse so the offsets are always correct
tokens_l = list(tokenize.generate_tokens(io.StringIO(contents).readline))
tokens = reversed(tokens_l)
for token_type, token_text, (srow, scol), (erow, ecol), _ in tokens:
if token_type == tokenize.STRING:
if token_type == FSTRING_START: # pragma: >=3.12 cover
fstring_depth += 1
elif token_type == FSTRING_END: # pragma: >=3.12 cover
fstring_depth -= 1
elif fstring_depth == 0 and token_type == tokenize.STRING:
new_text = handle_match(token_text)
splitcontents[
line_offsets[srow] + scol:
@ -60,7 +73,7 @@ def fix_strings(filename: str) -> int:
return 0
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
args = parser.parse_args(argv)
@ -77,4 +90,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,33 +1,53 @@
from __future__ import annotations
import argparse
import os.path
import re
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
parser.add_argument(
'--django', default=False, action='store_true',
help='Use Django-style test naming pattern (test*.py)',
mutex = parser.add_mutually_exclusive_group()
mutex.add_argument(
'--pytest',
dest='pattern',
action='store_const',
const=r'.*_test\.py',
default=r'.*_test\.py',
help='(the default) ensure tests match %(const)s',
)
mutex.add_argument(
'--pytest-test-first',
dest='pattern',
action='store_const',
const=r'test_.*\.py',
help='ensure tests match %(const)s',
)
mutex.add_argument(
'--django', '--unittest',
dest='pattern',
action='store_const',
const=r'test.*\.py',
help='ensure tests match %(const)s',
)
args = parser.parse_args(argv)
retcode = 0
test_name_pattern = r'test.*\.py' if args.django else r'.*_test\.py'
reg = re.compile(args.pattern)
for filename in args.filenames:
base = os.path.basename(filename)
if (
not re.match(test_name_pattern, base) and
not reg.fullmatch(base) and
not base == '__init__.py' and
not base == 'conftest.py'
):
retcode = 1
print(f'{filename} does not match pattern "{test_name_pattern}"')
print(f'{filename} does not match pattern "{args.pattern}"')
return retcode
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,13 +1,14 @@
from __future__ import annotations
import argparse
import os
from typing import Optional
from typing import Sequence
from collections.abc import Sequence
def _fix_file(
filename: str,
is_markdown: bool,
chars: Optional[bytes],
chars: bytes | None,
) -> bool:
with open(filename, mode='rb') as file_processed:
lines = file_processed.readlines()
@ -24,7 +25,7 @@ def _fix_file(
def _process_line(
line: bytes,
is_markdown: bool,
chars: Optional[bytes],
chars: bytes | None,
) -> bytes:
if line[-2:] == b'\r\n':
eol = b'\r\n'
@ -40,7 +41,7 @@ def _process_line(
return line.rstrip(chars) + eol
def main(argv: Optional[Sequence[str]] = None) -> int:
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
'--no-markdown-linebreak-ext',
@ -99,4 +100,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View file

@ -1,19 +1,19 @@
from __future__ import annotations
import subprocess
from typing import Any
from typing import Optional
from typing import Set
class CalledProcessError(RuntimeError):
pass
def added_files() -> Set[str]:
def added_files() -> set[str]:
cmd = ('git', 'diff', '--staged', '--name-only', '--diff-filter=A')
return set(cmd_output(*cmd).splitlines())
def cmd_output(*cmd: str, retcode: Optional[int] = 0, **kwargs: Any) -> str:
def cmd_output(*cmd: str, retcode: int | None = 0, **kwargs: Any) -> str:
kwargs.setdefault('stdout', subprocess.PIPE)
kwargs.setdefault('stderr', subprocess.PIPE)
proc = subprocess.Popen(cmd, **kwargs)
@ -22,3 +22,11 @@ def cmd_output(*cmd: str, retcode: Optional[int] = 0, **kwargs: Any) -> str:
if retcode is not None and proc.returncode != retcode:
raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
return stdout
def zsplit(s: str) -> list[str]:
s = s.strip('\0')
if s:
return s.split('\0')
else:
return []

View file

@ -1,4 +1,3 @@
covdefaults
coverage
pre-commit
pytest

View file

@ -1,6 +1,6 @@
[metadata]
name = pre_commit_hooks
version = 3.1.0
version = 6.0.0
description = Some out-of-the-box hooks for pre-commit.
long_description = file: README.md
long_description_content_type = text/markdown
@ -8,14 +8,10 @@ url = https://github.com/pre-commit/pre-commit-hooks
author = Anthony Sottile
author_email = asottile@umich.edu
license = MIT
license_file = LICENSE
license_files = LICENSE
classifiers =
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
@ -23,32 +19,38 @@ classifiers =
packages = find:
install_requires =
ruamel.yaml>=0.15
toml
python_requires = >=3.6.1
tomli>=1.1.0;python_version<"3.11"
python_requires = >=3.10
[options.packages.find]
exclude =
tests*
testing*
[options.entry_points]
console_scripts =
check-added-large-files = pre_commit_hooks.check_added_large_files:main
check-ast = pre_commit_hooks.check_ast:main
check-builtin-literals = pre_commit_hooks.check_builtin_literals:main
check-byte-order-marker = pre_commit_hooks.check_byte_order_marker:main
check-case-conflict = pre_commit_hooks.check_case_conflict:main
check-docstring-first = pre_commit_hooks.check_docstring_first:main
check-executables-have-shebangs = pre_commit_hooks.check_executables_have_shebangs:main
check-json = pre_commit_hooks.check_json:main
check-merge-conflict = pre_commit_hooks.check_merge_conflict:main
check-shebang-scripts-are-executable = pre_commit_hooks.check_shebang_scripts_are_executable:main
check-symlinks = pre_commit_hooks.check_symlinks:main
check-toml = pre_commit_hooks.check_toml:main
check-vcs-permalinks = pre_commit_hooks.check_vcs_permalinks:main
check-xml = pre_commit_hooks.check_xml:main
check-yaml = pre_commit_hooks.check_yaml:main
debug-statement-hook = pre_commit_hooks.debug_statement_hook:main
destroyed-symlinks = pre_commit_hooks.destroyed_symlinks:main
detect-aws-credentials = pre_commit_hooks.detect_aws_credentials:main
detect-private-key = pre_commit_hooks.detect_private_key:main
double-quote-string-fixer = pre_commit_hooks.string_fixer:main
end-of-file-fixer = pre_commit_hooks.end_of_file_fixer:main
file-contents-sorter = pre_commit_hooks.file_contents_sorter:main
fix-encoding-pragma = pre_commit_hooks.fix_encoding_pragma:main
fix-byte-order-marker = pre_commit_hooks.fix_byte_order_marker:main
forbid-new-submodules = pre_commit_hooks.forbid_new_submodules:main
mixed-line-ending = pre_commit_hooks.mixed_line_ending:main
name-tests-test = pre_commit_hooks.tests_should_end_in_test:main
@ -59,11 +61,6 @@ console_scripts =
sort-simple-yaml = pre_commit_hooks.sort_simple_yaml:main
trailing-whitespace-fixer = pre_commit_hooks.trailing_whitespace_fixer:main
[options.packages.find]
exclude =
tests*
testing*
[bdist_wheel]
universal = True
@ -75,7 +72,8 @@ check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
[mypy-testing.*]
disallow_untyped_defs = false

View file

@ -1,2 +1,4 @@
from __future__ import annotations
from setuptools import setup
setup()

View file

@ -0,0 +1,4 @@
{
"hello": "world",
"hello": "planet"
}

View file

@ -1,4 +1,7 @@
from __future__ import annotations
import os.path
import subprocess
TESTING_DIR = os.path.abspath(os.path.dirname(__file__))
@ -6,3 +9,8 @@ TESTING_DIR = os.path.abspath(os.path.dirname(__file__))
def get_resource_path(path):
return os.path.join(TESTING_DIR, 'resources', path)
def git_commit(*args, **kwargs):
cmd = ('git', 'commit', '--no-gpg-sign', '--no-verify', '--no-edit', *args)
subprocess.check_call(cmd, **kwargs)

View file

@ -1,10 +1,13 @@
import distutils.spawn
from __future__ import annotations
import shutil
import pytest
from pre_commit_hooks.check_added_large_files import find_large_added_files
from pre_commit_hooks.check_added_large_files import main
from pre_commit_hooks.util import cmd_output
from testing.util import git_commit
def test_nothing_added(temp_git_dir):
@ -40,6 +43,17 @@ def test_add_something_giant(temp_git_dir):
assert find_large_added_files(['f.py'], 10) == 0
def test_enforce_all(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.join('f.py').write('a' * 10000)
# Should fail, when not staged with enforce_all
assert find_large_added_files(['f.py'], 0, enforce_all=True) == 1
# Should pass, when not staged without enforce_all
assert find_large_added_files(['f.py'], 0, enforce_all=False) == 0
def test_added_file_not_in_pre_commits_list(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.join('f.py').write("print('hello world')")
@ -64,7 +78,7 @@ def test_integration(temp_git_dir):
def has_gitlfs():
return distutils.spawn.find_executable('git-lfs') is not None
return shutil.which('git-lfs') is not None
xfailif_no_gitlfs = pytest.mark.xfail(
@ -73,10 +87,9 @@ xfailif_no_gitlfs = pytest.mark.xfail(
@xfailif_no_gitlfs
def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
def test_allows_gitlfs(temp_git_dir): # pragma: no cover
with temp_git_dir.as_cwd():
monkeypatch.setenv('HOME', str(temp_git_dir.strpath))
cmd_output('git', 'lfs', 'install')
cmd_output('git', 'lfs', 'install', '--local')
temp_git_dir.join('f.py').write('a' * 10000)
cmd_output('git', 'lfs', 'track', 'f.py')
cmd_output('git', 'add', '--', '.')
@ -85,15 +98,37 @@ def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
@xfailif_no_gitlfs
def test_moves_with_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
def test_moves_with_gitlfs(temp_git_dir): # pragma: no cover
with temp_git_dir.as_cwd():
monkeypatch.setenv('HOME', str(temp_git_dir.strpath))
cmd_output('git', 'lfs', 'install')
cmd_output('git', 'lfs', 'install', '--local')
cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin')
# First add the file we're going to move
temp_git_dir.join('a.bin').write('a' * 10000)
cmd_output('git', 'add', '--', '.')
cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'foo')
git_commit('-am', 'foo')
# Now move it and make sure the hook still succeeds
cmd_output('git', 'mv', 'a.bin', 'b.bin')
assert main(('--maxkb', '9', 'b.bin')) == 0
@xfailif_no_gitlfs
def test_enforce_allows_gitlfs(temp_git_dir): # pragma: no cover
with temp_git_dir.as_cwd():
cmd_output('git', 'lfs', 'install', '--local')
temp_git_dir.join('f.py').write('a' * 10000)
cmd_output('git', 'lfs', 'track', 'f.py')
cmd_output('git', 'add', '--', '.')
# With --enforce-all large files on git lfs should succeed
assert main(('--enforce-all', '--maxkb', '9', 'f.py')) == 0
@xfailif_no_gitlfs
def test_enforce_allows_gitlfs_after_commit(temp_git_dir): # pragma: no cover
with temp_git_dir.as_cwd():
cmd_output('git', 'lfs', 'install', '--local')
temp_git_dir.join('f.py').write('a' * 10000)
cmd_output('git', 'lfs', 'track', 'f.py')
cmd_output('git', 'add', '--', '.')
git_commit('-am', 'foo')
# With --enforce-all large files on git lfs should succeed
assert main(('--enforce-all', '--maxkb', '9', 'f.py')) == 0

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from pre_commit_hooks.check_ast import main
from testing.util import get_resource_path

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import ast
import pytest
@ -36,11 +38,6 @@ t1 = ()
'''
@pytest.fixture
def visitor():
return Visitor()
@pytest.mark.parametrize(
('expression', 'calls'),
[
@ -83,7 +80,8 @@ def visitor():
('builtins.tuple()', []),
],
)
def test_non_dict_exprs(visitor, expression, calls):
def test_non_dict_exprs(expression, calls):
visitor = Visitor(ignore=set())
visitor.visit(ast.parse(expression))
assert visitor.builtin_type_calls == calls
@ -100,7 +98,8 @@ def test_non_dict_exprs(visitor, expression, calls):
('builtins.dict()', []),
],
)
def test_dict_allow_kwargs_exprs(visitor, expression, calls):
def test_dict_allow_kwargs_exprs(expression, calls):
visitor = Visitor(ignore=set())
visitor.visit(ast.parse(expression))
assert visitor.builtin_type_calls == calls
@ -112,17 +111,18 @@ def test_dict_allow_kwargs_exprs(visitor, expression, calls):
('dict(a=1, b=2, c=3)', [Call('dict', 1, 0)]),
("dict(**{'a': 1, 'b': 2, 'c': 3})", [Call('dict', 1, 0)]),
('builtins.dict()', []),
pytest.param('f(dict())', [Call('dict', 1, 2)], id='nested'),
],
)
def test_dict_no_allow_kwargs_exprs(expression, calls):
visitor = Visitor(allow_dict_kwargs=False)
visitor = Visitor(ignore=set(), allow_dict_kwargs=False)
visitor.visit(ast.parse(expression))
assert visitor.builtin_type_calls == calls
def test_ignore_constructors():
visitor = Visitor(
ignore=('complex', 'dict', 'float', 'int', 'list', 'str', 'tuple'),
ignore={'complex', 'dict', 'float', 'int', 'list', 'str', 'tuple'},
)
visitor.visit(ast.parse(BUILTIN_CONSTRUCTORS))
assert visitor.builtin_type_calls == []
@ -131,19 +131,19 @@ def test_ignore_constructors():
def test_failing_file(tmpdir):
f = tmpdir.join('f.py')
f.write(BUILTIN_CONSTRUCTORS)
rc = main([f.strpath])
rc = main([str(f)])
assert rc == 1
def test_passing_file(tmpdir):
f = tmpdir.join('f.py')
f.write(BUILTIN_LITERALS)
rc = main([f.strpath])
rc = main([str(f)])
assert rc == 0
def test_failing_file_ignore_all(tmpdir):
f = tmpdir.join('f.py')
f.write(BUILTIN_CONSTRUCTORS)
rc = main(['--ignore=complex,dict,float,int,list,str,tuple', f.strpath])
rc = main(['--ignore=complex,dict,float,int,list,str,tuple', str(f)])
assert rc == 0

View file

@ -1,6 +1,26 @@
from __future__ import annotations
import sys
import pytest
from pre_commit_hooks.check_case_conflict import find_conflicting_filenames
from pre_commit_hooks.check_case_conflict import main
from pre_commit_hooks.check_case_conflict import parents
from pre_commit_hooks.util import cmd_output
from testing.util import git_commit
skip_win32 = pytest.mark.skipif(
sys.platform == 'win32',
reason='case conflicts between directories and files',
)
def test_parents():
assert set(parents('a')) == set()
assert set(parents('a/b')) == {'a'}
assert set(parents('a/b/c')) == {'a/b', 'a'}
assert set(parents('a/b/c/d')) == {'a/b/c', 'a/b', 'a'}
def test_nothing_added(temp_git_dir):
@ -26,6 +46,36 @@ def test_adding_something_with_conflict(temp_git_dir):
assert find_conflicting_filenames(['f.py', 'F.py']) == 1
@skip_win32 # pragma: win32 no cover
def test_adding_files_with_conflicting_directories(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.mkdir('dir').join('x').write('foo')
temp_git_dir.mkdir('DIR').join('y').write('foo')
cmd_output('git', 'add', '-A')
assert find_conflicting_filenames([]) == 1
@skip_win32 # pragma: win32 no cover
def test_adding_files_with_conflicting_deep_directories(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.mkdir('x').mkdir('y').join('z').write('foo')
temp_git_dir.join('X').write('foo')
cmd_output('git', 'add', '-A')
assert find_conflicting_filenames([]) == 1
@skip_win32 # pragma: win32 no cover
def test_adding_file_with_conflicting_directory(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.mkdir('dir').join('x').write('foo')
temp_git_dir.join('DIR').write('foo')
cmd_output('git', 'add', '-A')
assert find_conflicting_filenames([]) == 1
def test_added_file_not_in_pre_commits_list(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.join('f.py').write("print('hello world')")
@ -38,7 +88,7 @@ def test_file_conflicts_with_committed_file(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.join('f.py').write("print('hello world')")
cmd_output('git', 'add', 'f.py')
cmd_output('git', 'commit', '--no-gpg-sign', '-n', '-m', 'Add f.py')
git_commit('-m', 'Add f.py')
temp_git_dir.join('F.py').write("print('hello world')")
cmd_output('git', 'add', 'F.py')
@ -46,6 +96,19 @@ def test_file_conflicts_with_committed_file(temp_git_dir):
assert find_conflicting_filenames(['F.py']) == 1
@skip_win32 # pragma: win32 no cover
def test_file_conflicts_with_committed_dir(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.mkdir('dir').join('x').write('foo')
cmd_output('git', 'add', '-A')
git_commit('-m', 'Add f.py')
temp_git_dir.join('DIR').write('foo')
cmd_output('git', 'add', '-A')
assert find_conflicting_filenames([]) == 1
def test_integration(temp_git_dir):
with temp_git_dir.as_cwd():
assert main(argv=[]) == 0

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.check_docstring_first import check_docstring_first
@ -15,7 +17,7 @@ TESTS = (
b'from __future__ import unicode_literals\n'
b'"foo"\n',
1,
'{filename}:2 Module docstring appears after code '
'{filename}:2: Module docstring appears after code '
'(code seen on line 1).\n',
),
# Test double docstring
@ -24,7 +26,7 @@ TESTS = (
b'from __future__ import absolute_import\n'
b'"fake docstring"\n',
1,
'{filename}:3 Multiple module docstrings '
'{filename}:3: Multiple module docstrings '
'(first docstring on line 1).\n',
),
# Test multiple lines of code above
@ -33,7 +35,7 @@ TESTS = (
b'import sys\n'
b'"docstring"\n',
1,
'{filename}:3 Module docstring appears after code '
'{filename}:3: Module docstring appears after code '
'(code seen on line 1).\n',
),
# String literals in expressions are ok.
@ -56,12 +58,12 @@ def test_unit(capsys, contents, expected, expected_out):
def test_integration(tmpdir, capsys, contents, expected, expected_out):
f = tmpdir.join('test.py')
f.write_binary(contents)
assert main([f.strpath]) == expected
assert capsys.readouterr()[0] == expected_out.format(filename=f.strpath)
assert main([str(f)]) == expected
assert capsys.readouterr()[0] == expected_out.format(filename=str(f))
def test_arbitrary_encoding(tmpdir):
f = tmpdir.join('f.py')
contents = '# -*- coding: cp1252\nx = "£"'.encode('cp1252')
f.write_binary(contents)
assert main([f.strpath]) == 0
assert main([str(f)]) == 0

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import os
import sys
@ -25,7 +27,7 @@ skip_win32 = pytest.mark.skipif(
def test_has_shebang(content, tmpdir):
path = tmpdir.join('path')
path.write(content, 'wb')
assert main((path.strpath,)) == 0
assert main((str(path),)) == 0
@skip_win32 # pragma: win32 no cover
@ -41,7 +43,7 @@ def test_has_shebang(content, tmpdir):
def test_bad_shebang(content, tmpdir, capsys):
path = tmpdir.join('path')
path.write(content, 'wb')
assert main((path.strpath,)) == 1
assert main((str(path),)) == 1
_, stderr = capsys.readouterr()
assert stderr.startswith(f'{path}: marked executable but')
@ -73,6 +75,21 @@ def test_check_git_filemode_passing(tmpdir):
assert check_executables_have_shebangs._check_git_filemode(files) == 0
def test_check_git_filemode_passing_unusual_characters(tmpdir):
with tmpdir.as_cwd():
cmd_output('git', 'init', '.')
f = tmpdir.join('mañana.txt')
f.write('#!/usr/bin/env bash')
f_path = str(f)
cmd_output('chmod', '+x', f_path)
cmd_output('git', 'add', f_path)
cmd_output('git', 'update-index', '--chmod=+x', f_path)
files = (f_path,)
assert check_executables_have_shebangs._check_git_filemode(files) == 0
def test_check_git_filemode_failing(tmpdir):
with tmpdir.as_cwd():
cmd_output('git', 'init', '.')

View file

@ -0,0 +1,63 @@
from __future__ import annotations
import os.path
import re
import pytest
from pre_commit_hooks.check_yaml import yaml
@pytest.fixture(scope='module')
def hook_re():
here = os.path.dirname(__file__)
with open(os.path.join(here, '..', '.pre-commit-hooks.yaml')) as f:
hook_defs = yaml.load(f)
hook, = (
hook
for hook in hook_defs
if hook['id'] == 'check-illegal-windows-names'
)
yield re.compile(hook['files'])
@pytest.mark.parametrize(
's',
(
pytest.param('aux.txt', id='with ext'),
pytest.param('aux', id='without ext'),
pytest.param('AuX.tXt', id='capitals'),
pytest.param('com7.dat', id='com with digit'),
pytest.param(':', id='bare colon'),
pytest.param('file:Zone.Identifier', id='mid colon'),
pytest.param('path/COM¹.json', id='com with superscript'),
pytest.param('dir/LPT³.toml', id='lpt with superscript'),
pytest.param('with < less than', id='with less than'),
pytest.param('Fast or Slow?.md', id='with question mark'),
pytest.param('with "double" quotes', id='with double quotes'),
pytest.param('with_null\x00byte', id='with null byte'),
pytest.param('ends_with.', id='ends with period'),
pytest.param('ends_with ', id='ends with space'),
pytest.param('ends_with\t', id='ends with tab'),
pytest.param('dir/ends./with.txt', id='directory ends with period'),
pytest.param('dir/ends /with.txt', id='directory ends with space'),
),
)
def test_check_illegal_windows_names_matches(hook_re, s):
assert hook_re.search(s)
@pytest.mark.parametrize(
's',
(
pytest.param('README.md', id='standard file'),
pytest.param('foo.aux', id='as ext'),
pytest.param('com.dat', id='com without digit'),
pytest.param('.python-version', id='starts with period'),
pytest.param(' pseudo nan', id='with spaces'),
pytest.param('!@#$%^&;=≤\'~`¡¿€🤗', id='with allowed characters'),
pytest.param('path.to/file.py', id='standard path'),
),
)
def test_check_illegal_windows_names_does_not_match(hook_re, s):
assert hook_re.search(s) is None

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.check_json import main
@ -9,6 +11,7 @@ from testing.util import get_resource_path
('bad_json.notjson', 1),
('bad_json_latin1.nonjson', 1),
('ok_json.json', 0),
('duplicate_key_json.notjson', 1),
),
)
def test_main(capsys, filename, expected_retval):

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import os
import shutil
@ -6,6 +8,7 @@ import pytest
from pre_commit_hooks.check_merge_conflict import main
from pre_commit_hooks.util import cmd_output
from testing.util import get_resource_path
from testing.util import git_commit
@pytest.fixture
@ -16,23 +19,23 @@ def f1_is_a_conflict_file(tmpdir):
repo2 = tmpdir.join('repo2')
repo2_f1 = repo2.join('f1')
cmd_output('git', 'init', '--', repo1.strpath)
cmd_output('git', 'init', '--', str(repo1))
with repo1.as_cwd():
repo1_f1.ensure()
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1')
git_commit('-m', 'commit1')
cmd_output('git', 'clone', repo1.strpath, repo2.strpath)
cmd_output('git', 'clone', str(repo1), str(repo2))
# Commit in master
# Commit in mainline
with repo1.as_cwd():
repo1_f1.write('parent\n')
cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'master commit2')
git_commit('-am', 'mainline commit2')
# Commit in clone and pull
with repo2.as_cwd():
repo2_f1.write('child\n')
cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'clone commit2')
git_commit('-am', 'clone commit2')
cmd_output('git', 'pull', '--no-rebase', retcode=None)
# We should end up in a merge conflict!
f1 = repo2_f1.read()
@ -71,24 +74,24 @@ def repository_pending_merge(tmpdir):
repo2 = tmpdir.join('repo2')
repo2_f1 = repo2.join('f1')
repo2_f2 = repo2.join('f2')
cmd_output('git', 'init', repo1.strpath)
cmd_output('git', 'init', str(repo1))
with repo1.as_cwd():
repo1_f1.ensure()
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1')
git_commit('-m', 'commit1')
cmd_output('git', 'clone', repo1.strpath, repo2.strpath)
cmd_output('git', 'clone', str(repo1), str(repo2))
# Commit in master
# Commit in mainline
with repo1.as_cwd():
repo1_f1.write('parent\n')
cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'master commit2')
git_commit('-am', 'mainline commit2')
# Commit in clone and pull without committing
with repo2.as_cwd():
repo2_f2.write('child\n')
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'clone commit2')
git_commit('-m', 'clone commit2')
cmd_output('git', 'pull', '--no-commit', '--no-rebase')
# We should end up in a pending merge
assert repo2_f1.read() == 'parent\n'
@ -98,12 +101,18 @@ def repository_pending_merge(tmpdir):
@pytest.mark.usefixtures('f1_is_a_conflict_file')
def test_merge_conflicts_git():
def test_merge_conflicts_git(capsys):
assert main(['f1']) == 1
out, _ = capsys.readouterr()
assert out == (
"f1:1: Merge conflict string '<<<<<<<' found\n"
"f1:3: Merge conflict string '=======' found\n"
"f1:5: Merge conflict string '>>>>>>>' found\n"
)
@pytest.mark.parametrize(
'contents', (b'<<<<<<< HEAD\n', b'=======\n', b'>>>>>>> master\n'),
'contents', (b'<<<<<<< HEAD\n', b'=======\n', b'>>>>>>> main\n'),
)
def test_merge_conflicts_failing(contents, repository_pending_merge):
repository_pending_merge.join('f2').write_binary(contents)
@ -134,3 +143,15 @@ def test_care_when_assumed_merge(tmpdir):
f = tmpdir.join('README.md')
f.write_binary(b'problem\n=======\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1
def test_worktree_merge_conflicts(f1_is_a_conflict_file, tmpdir, capsys):
worktree = tmpdir.join('worktree')
cmd_output('git', 'worktree', 'add', str(worktree))
with worktree.as_cwd():
cmd_output(
'git', 'pull', '--no-rebase', 'origin', 'HEAD', retcode=None,
)
msg = f1_is_a_conflict_file.join('.git/worktrees/worktree/MERGE_MSG')
assert msg.exists()
test_merge_conflicts_git(capsys)

View file

@ -0,0 +1,89 @@
from __future__ import annotations
import os
import pytest
from pre_commit_hooks.check_shebang_scripts_are_executable import \
_check_git_filemode
from pre_commit_hooks.check_shebang_scripts_are_executable import main
from pre_commit_hooks.util import cmd_output
def test_check_git_filemode_passing(tmpdir):
with tmpdir.as_cwd():
cmd_output('git', 'init', '.')
f = tmpdir.join('f')
f.write('#!/usr/bin/env bash')
f_path = str(f)
cmd_output('chmod', '+x', f_path)
cmd_output('git', 'add', f_path)
cmd_output('git', 'update-index', '--chmod=+x', f_path)
g = tmpdir.join('g').ensure()
g_path = str(g)
cmd_output('git', 'add', g_path)
files = [f_path, g_path]
assert _check_git_filemode(files) == 0
# this is the one we should trigger on
h = tmpdir.join('h')
h.write('#!/usr/bin/env bash')
h_path = str(h)
cmd_output('git', 'add', h_path)
files = [h_path]
assert _check_git_filemode(files) == 1
def test_check_git_filemode_passing_unusual_characters(tmpdir):
with tmpdir.as_cwd():
cmd_output('git', 'init', '.')
f = tmpdir.join('mañana.txt')
f.write('#!/usr/bin/env bash')
f_path = str(f)
cmd_output('chmod', '+x', f_path)
cmd_output('git', 'add', f_path)
cmd_output('git', 'update-index', '--chmod=+x', f_path)
files = (f_path,)
assert _check_git_filemode(files) == 0
def test_check_git_filemode_failing(tmpdir):
with tmpdir.as_cwd():
cmd_output('git', 'init', '.')
f = tmpdir.join('f').ensure()
f.write('#!/usr/bin/env bash')
f_path = str(f)
cmd_output('git', 'add', f_path)
files = (f_path,)
assert _check_git_filemode(files) == 1
@pytest.mark.parametrize(
('content', 'mode', 'expected'),
(
pytest.param('#!python', '+x', 0, id='shebang with executable'),
pytest.param('#!python', '-x', 1, id='shebang without executable'),
pytest.param('', '+x', 0, id='no shebang with executable'),
pytest.param('', '-x', 0, id='no shebang without executable'),
),
)
def test_git_executable_shebang(temp_git_dir, content, mode, expected):
with temp_git_dir.as_cwd():
path = temp_git_dir.join('path')
path.write(content)
cmd_output('git', 'add', str(path))
cmd_output('chmod', mode, str(path))
cmd_output('git', 'update-index', f'--chmod={mode}', str(path))
# simulate how identify chooses that something is executable
filenames = [path for path in [str(path)] if os.access(path, os.X_OK)]
assert main(filenames) == expected

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import os
import pytest
@ -16,8 +18,8 @@ def test_main(tmpdir, dest, expected): # pragma: no cover (symlinks)
tmpdir.join('exists').ensure()
symlink = tmpdir.join('symlink')
symlink.mksymlinkto(tmpdir.join(dest))
assert main((symlink.strpath,)) == expected
assert main((str(symlink),)) == expected
def test_main_normal_file(tmpdir):
assert main((tmpdir.join('f').ensure().strpath,)) == 0
assert main((str(tmpdir.join('f').ensure()),)) == 0

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from pre_commit_hooks.check_toml import main
@ -8,7 +10,7 @@ key = # INVALID
= "no key name" # INVALID
""")
ret = main((filename.strpath,))
ret = main((str(filename),))
assert ret == 1
@ -25,12 +27,12 @@ name = "John"
dob = 1979-05-27T07:32:00-08:00 # First class dates
""",
)
ret = main((filename.strpath,))
ret = main((str(filename),))
assert ret == 0
def test_toml_good_unicode(tmpdir):
filename = tmpdir.join('f')
filename.write_binary('letter = "\N{SNOWMAN}"\n'.encode())
ret = main((filename.strpath,))
ret = main((str(filename),))
assert ret == 0

View file

@ -1,9 +1,11 @@
from __future__ import annotations
from pre_commit_hooks.check_vcs_permalinks import main
def test_trivial(tmpdir):
f = tmpdir.join('f.txt').ensure()
assert not main((f.strpath,))
assert not main((str(f),))
def test_passing(tmpdir):
@ -11,24 +13,28 @@ def test_passing(tmpdir):
f.write_binary(
# permalinks are ok
b'https://github.com/asottile/test/blob/649e6/foo%20bar#L1\n'
# tags are ok
b'https://github.com/asottile/test/blob/1.0.0/foo%20bar#L1\n'
# links to files but not line numbers are ok
b'https://github.com/asottile/test/blob/master/foo%20bar\n'
b'https://github.com/asottile/test/blob/main/foo%20bar\n'
# regression test for overly-greedy regex
b'https://github.com/ yes / no ? /blob/master/foo#L1\n',
b'https://github.com/ yes / no ? /blob/main/foo#L1\n',
)
assert not main((f.strpath,))
assert not main((str(f),))
def test_failing(tmpdir, capsys):
with tmpdir.as_cwd():
tmpdir.join('f.txt').write_binary(
b'https://github.com/asottile/test/blob/master/foo#L1\n',
b'https://github.com/asottile/test/blob/main/foo#L1\n'
b'https://example.com/asottile/test/blob/main/foo#L1\n',
)
assert main(('f.txt',))
assert main(('f.txt', '--additional-github-domain', 'example.com'))
out, _ = capsys.readouterr()
assert out == (
'f.txt:1:https://github.com/asottile/test/blob/master/foo#L1\n'
'f.txt:1:https://github.com/asottile/test/blob/main/foo#L1\n'
'f.txt:2:https://example.com/asottile/test/blob/main/foo#L1\n'
'\n'
'Non-permanent github link detected.\n'
'On any page on github press [y] to load a permalink.\n'

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.check_xml import main

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.check_yaml import main
@ -20,16 +22,16 @@ def test_main_allow_multiple_documents(tmpdir):
f.write('---\nfoo\n---\nbar\n')
# should fail without the setting
assert main((f.strpath,))
assert main((str(f),))
# should pass when we allow multiple documents
assert not main(('--allow-multiple-documents', f.strpath))
assert not main(('--allow-multiple-documents', str(f)))
def test_fails_even_with_allow_multiple_documents(tmpdir):
f = tmpdir.join('test.yaml')
f.write('[')
assert main(('--allow-multiple-documents', f.strpath))
assert main(('--allow-multiple-documents', str(f)))
def test_main_unsafe(tmpdir):
@ -40,12 +42,12 @@ def test_main_unsafe(tmpdir):
' deadbeefdeadbeefdeadbeef\n',
)
# should fail "safe" check
assert main((f.strpath,))
assert main((str(f),))
# should pass when we allow unsafe documents
assert not main(('--unsafe', f.strpath))
assert not main(('--unsafe', str(f)))
def test_main_unsafe_still_fails_on_syntax_errors(tmpdir):
f = tmpdir.join('test.yaml')
f.write('[')
assert main(('--unsafe', f.strpath))
assert main(('--unsafe', str(f)))

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.util import cmd_output
@ -6,5 +8,5 @@ from pre_commit_hooks.util import cmd_output
@pytest.fixture
def temp_git_dir(tmpdir):
git_dir = tmpdir.join('gits')
cmd_output('git', 'init', '--', git_dir.strpath)
cmd_output('git', 'init', '--', str(git_dir))
yield git_dir

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import ast
from pre_commit_hooks.debug_statement_hook import Debug
@ -33,7 +35,7 @@ def test_finds_breakpoint():
def test_returns_one_for_failing_file(tmpdir):
f_py = tmpdir.join('f.py')
f_py.write('def f():\n import pdb; pdb.set_trace()')
ret = main([f_py.strpath])
ret = main([str(f_py)])
assert ret == 1
@ -50,10 +52,12 @@ def test_syntaxerror_file():
def test_non_utf8_file(tmpdir):
f_py = tmpdir.join('f.py')
f_py.write_binary('# -*- coding: cp1252 -*-\nx = ""\n'.encode('cp1252'))
assert main((f_py.strpath,)) == 0
assert main((str(f_py),)) == 0
def test_py37_breakpoint(tmpdir):
def test_py37_breakpoint(tmpdir, capsys):
f_py = tmpdir.join('f.py')
f_py.write('def f():\n breakpoint()\n')
assert main((f_py.strpath,)) == 1
assert main((str(f_py),)) == 1
out, _ = capsys.readouterr()
assert out == f'{f_py}:2:4: breakpoint called\n'

View file

@ -0,0 +1,75 @@
from __future__ import annotations
import os
import subprocess
import pytest
from pre_commit_hooks.destroyed_symlinks import find_destroyed_symlinks
from pre_commit_hooks.destroyed_symlinks import main
from testing.util import git_commit
TEST_SYMLINK = 'test_symlink'
TEST_SYMLINK_TARGET = '/doesnt/really/matters'
TEST_FILE = 'test_file'
TEST_FILE_RENAMED = f'{TEST_FILE}_renamed'
@pytest.fixture
def repo_with_destroyed_symlink(tmpdir):
source_repo = tmpdir.join('src')
os.makedirs(source_repo, exist_ok=True)
test_repo = tmpdir.join('test')
with source_repo.as_cwd():
subprocess.check_call(('git', 'init'))
os.symlink(TEST_SYMLINK_TARGET, TEST_SYMLINK)
with open(TEST_FILE, 'w') as f:
print('some random content', file=f)
subprocess.check_call(('git', 'add', '.'))
git_commit('-m', 'initial')
assert b'120000 ' in subprocess.check_output(
('git', 'cat-file', '-p', 'HEAD^{tree}'),
)
subprocess.check_call(
('git', '-c', 'core.symlinks=false', 'clone', source_repo, test_repo),
)
with test_repo.as_cwd():
subprocess.check_call(
('git', 'config', '--local', 'core.symlinks', 'true'),
)
subprocess.check_call(('git', 'mv', TEST_FILE, TEST_FILE_RENAMED))
assert not os.path.islink(test_repo.join(TEST_SYMLINK))
yield test_repo
def test_find_destroyed_symlinks(repo_with_destroyed_symlink):
with repo_with_destroyed_symlink.as_cwd():
assert find_destroyed_symlinks([]) == []
assert main([]) == 0
subprocess.check_call(('git', 'add', TEST_SYMLINK))
assert find_destroyed_symlinks([TEST_SYMLINK]) == [TEST_SYMLINK]
assert find_destroyed_symlinks([]) == []
assert main([]) == 0
assert find_destroyed_symlinks([TEST_FILE_RENAMED, TEST_FILE]) == []
ALL_STAGED = [TEST_SYMLINK, TEST_FILE_RENAMED]
assert find_destroyed_symlinks(ALL_STAGED) == [TEST_SYMLINK]
assert main(ALL_STAGED) != 0
with open(TEST_SYMLINK, 'a') as f:
print(file=f) # add trailing newline
subprocess.check_call(['git', 'add', TEST_SYMLINK])
assert find_destroyed_symlinks(ALL_STAGED) == [TEST_SYMLINK]
assert main(ALL_STAGED) != 0
with open(TEST_SYMLINK, 'w') as f:
print('0' * len(TEST_SYMLINK_TARGET), file=f)
subprocess.check_call(('git', 'add', TEST_SYMLINK))
assert find_destroyed_symlinks(ALL_STAGED) == []
assert main(ALL_STAGED) == 0
with open(TEST_SYMLINK, 'w') as f:
print('0' * (len(TEST_SYMLINK_TARGET) + 3), file=f)
subprocess.check_call(('git', 'add', TEST_SYMLINK))
assert find_destroyed_symlinks(ALL_STAGED) == []
assert main(ALL_STAGED) == 0

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from unittest.mock import patch
import pytest
@ -13,15 +15,15 @@ from testing.util import get_resource_path
('env_vars', 'values'),
(
({}, set()),
({'AWS_DUMMY_KEY': '/foo'}, set()),
({'AWS_PLACEHOLDER_KEY': '/foo'}, set()),
({'AWS_CONFIG_FILE': '/foo'}, {'/foo'}),
({'AWS_CREDENTIAL_FILE': '/foo'}, {'/foo'}),
({'AWS_SHARED_CREDENTIALS_FILE': '/foo'}, {'/foo'}),
({'BOTO_CONFIG': '/foo'}, {'/foo'}),
({'AWS_DUMMY_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar'}, {'/bar'}),
({'AWS_PLACEHOLDER_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar'}, {'/bar'}),
(
{
'AWS_DUMMY_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar',
'AWS_PLACEHOLDER_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar',
'AWS_CREDENTIAL_FILE': '/baz',
},
{'/bar', '/baz'},
@ -44,13 +46,16 @@ def test_get_aws_credentials_file_from_env(env_vars, values):
('env_vars', 'values'),
(
({}, set()),
({'AWS_DUMMY_KEY': 'foo'}, set()),
({'AWS_PLACEHOLDER_KEY': 'foo'}, set()),
({'AWS_SECRET_ACCESS_KEY': 'foo'}, {'foo'}),
({'AWS_SECURITY_TOKEN': 'foo'}, {'foo'}),
({'AWS_SESSION_TOKEN': 'foo'}, {'foo'}),
({'AWS_SESSION_TOKEN': ''}, set()),
({'AWS_SESSION_TOKEN': 'foo', 'AWS_SECURITY_TOKEN': ''}, {'foo'}),
({'AWS_DUMMY_KEY': 'foo', 'AWS_SECRET_ACCESS_KEY': 'bar'}, {'bar'}),
(
{'AWS_PLACEHOLDER_KEY': 'foo', 'AWS_SECRET_ACCESS_KEY': 'bar'},
{'bar'},
),
(
{'AWS_SECRET_ACCESS_KEY': 'foo', 'AWS_SECURITY_TOKEN': 'bar'},
{'foo', 'bar'},

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.detect_private_key import main
@ -10,6 +12,8 @@ TESTS = (
(b'-----BEGIN OPENSSH PRIVATE KEY-----', 1),
(b'PuTTY-User-Key-File-2: ssh-rsa', 1),
(b'---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----', 1),
(b'-----BEGIN ENCRYPTED PRIVATE KEY-----', 1),
(b'-----BEGIN OpenVPN Static key V1-----', 1),
(b'ssh-rsa DATA', 0),
(b'ssh-dsa DATA', 0),
# Some arbitrary binary data
@ -21,4 +25,4 @@ TESTS = (
def test_main(input_s, expected_retval, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
assert main([path.strpath]) == expected_retval
assert main([str(path)]) == expected_retval

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import io
import pytest
@ -35,7 +37,7 @@ def test_integration(input_s, expected_retval, output, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
ret = main([path.strpath])
ret = main([str(path)])
file_output = path.read_binary()
assert file_output == output

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.file_contents_sorter import FAIL
@ -6,28 +8,93 @@ from pre_commit_hooks.file_contents_sorter import PASS
@pytest.mark.parametrize(
('input_s', 'expected_retval', 'output'),
('input_s', 'argv', 'expected_retval', 'output'),
(
(b'', FAIL, b'\n'),
(b'lonesome\n', PASS, b'lonesome\n'),
(b'missing_newline', FAIL, b'missing_newline\n'),
(b'newline\nmissing', FAIL, b'missing\nnewline\n'),
(b'missing\nnewline', FAIL, b'missing\nnewline\n'),
(b'alpha\nbeta\n', PASS, b'alpha\nbeta\n'),
(b'beta\nalpha\n', FAIL, b'alpha\nbeta\n'),
(b'C\nc\n', PASS, b'C\nc\n'),
(b'c\nC\n', FAIL, b'C\nc\n'),
(b'mag ical \n tre vor\n', FAIL, b' tre vor\nmag ical \n'),
(b'@\n-\n_\n#\n', FAIL, b'#\n-\n@\n_\n'),
(b'extra\n\n\nwhitespace\n', FAIL, b'extra\nwhitespace\n'),
(b'whitespace\n\n\nextra\n', FAIL, b'extra\nwhitespace\n'),
(b'', [], PASS, b''),
(b'\n', [], FAIL, b''),
(b'\n\n', [], FAIL, b''),
(b'lonesome\n', [], PASS, b'lonesome\n'),
(b'missing_newline', [], FAIL, b'missing_newline\n'),
(b'newline\nmissing', [], FAIL, b'missing\nnewline\n'),
(b'missing\nnewline', [], FAIL, b'missing\nnewline\n'),
(b'alpha\nbeta\n', [], PASS, b'alpha\nbeta\n'),
(b'beta\nalpha\n', [], FAIL, b'alpha\nbeta\n'),
(b'C\nc\n', [], PASS, b'C\nc\n'),
(b'c\nC\n', [], FAIL, b'C\nc\n'),
(b'mag ical \n tre vor\n', [], FAIL, b' tre vor\nmag ical \n'),
(b'@\n-\n_\n#\n', [], FAIL, b'#\n-\n@\n_\n'),
(b'extra\n\n\nwhitespace\n', [], FAIL, b'extra\nwhitespace\n'),
(b'whitespace\n\n\nextra\n', [], FAIL, b'extra\nwhitespace\n'),
(
b'fee\nFie\nFoe\nfum\n',
[],
FAIL,
b'Fie\nFoe\nfee\nfum\n',
),
(
b'Fie\nFoe\nfee\nfum\n',
[],
PASS,
b'Fie\nFoe\nfee\nfum\n',
),
(
b'fee\nFie\nFoe\nfum\n',
['--ignore-case'],
PASS,
b'fee\nFie\nFoe\nfum\n',
),
(
b'Fie\nFoe\nfee\nfum\n',
['--ignore-case'],
FAIL,
b'fee\nFie\nFoe\nfum\n',
),
(
b'Fie\nFoe\nfee\nfee\nfum\n',
['--ignore-case'],
FAIL,
b'fee\nfee\nFie\nFoe\nfum\n',
),
(
b'Fie\nFoe\nfee\nfum\n',
['--unique'],
PASS,
b'Fie\nFoe\nfee\nfum\n',
),
(
b'Fie\nFie\nFoe\nfee\nfum\n',
['--unique'],
FAIL,
b'Fie\nFoe\nfee\nfum\n',
),
),
)
def test_integration(input_s, expected_retval, output, tmpdir):
def test_integration(input_s, argv, expected_retval, output, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
output_retval = main([path.strpath])
output_retval = main([str(path)] + argv)
assert path.read_binary() == output
assert output_retval == expected_retval
@pytest.mark.parametrize(
('input_s', 'argv'),
(
(
b'fee\nFie\nFoe\nfum\n',
['--unique', '--ignore-case'],
),
(
b'fee\nfee\nFie\nFoe\nfum\n',
['--unique', '--ignore-case'],
),
),
)
def test_integration_invalid_args(input_s, argv, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
with pytest.raises(SystemExit):
main([str(path)] + argv)

View file

@ -1,13 +1,15 @@
from pre_commit_hooks import check_byte_order_marker
from __future__ import annotations
from pre_commit_hooks import fix_byte_order_marker
def test_failure(tmpdir):
f = tmpdir.join('f.txt')
f.write_text('ohai', encoding='utf-8-sig')
assert check_byte_order_marker.main((f.strpath,)) == 1
assert fix_byte_order_marker.main((str(f),)) == 1
def test_success(tmpdir):
f = tmpdir.join('f.txt')
f.write_text('ohai', encoding='utf-8')
assert check_byte_order_marker.main((f.strpath,)) == 0
assert fix_byte_order_marker.main((str(f),)) == 0

View file

@ -1,159 +0,0 @@
import io
import pytest
from pre_commit_hooks.fix_encoding_pragma import _normalize_pragma
from pre_commit_hooks.fix_encoding_pragma import fix_encoding_pragma
from pre_commit_hooks.fix_encoding_pragma import main
def test_integration_inserting_pragma(tmpdir):
path = tmpdir.join('foo.py')
path.write_binary(b'import httplib\n')
assert main((path.strpath,)) == 1
assert path.read_binary() == (
b'# -*- coding: utf-8 -*-\n'
b'import httplib\n'
)
def test_integration_ok(tmpdir):
path = tmpdir.join('foo.py')
path.write_binary(b'# -*- coding: utf-8 -*-\nx = 1\n')
assert main((path.strpath,)) == 0
def test_integration_remove(tmpdir):
path = tmpdir.join('foo.py')
path.write_binary(b'# -*- coding: utf-8 -*-\nx = 1\n')
assert main((path.strpath, '--remove')) == 1
assert path.read_binary() == b'x = 1\n'
def test_integration_remove_ok(tmpdir):
path = tmpdir.join('foo.py')
path.write_binary(b'x = 1\n')
assert main((path.strpath, '--remove')) == 0
@pytest.mark.parametrize(
'input_str',
(
b'',
(
b'# -*- coding: utf-8 -*-\n'
b'x = 1\n'
),
(
b'#!/usr/bin/env python\n'
b'# -*- coding: utf-8 -*-\n'
b'foo = "bar"\n'
),
),
)
def test_ok_inputs(input_str):
bytesio = io.BytesIO(input_str)
assert fix_encoding_pragma(bytesio) == 0
bytesio.seek(0)
assert bytesio.read() == input_str
@pytest.mark.parametrize(
('input_str', 'output'),
(
(
b'import httplib\n',
b'# -*- coding: utf-8 -*-\n'
b'import httplib\n',
),
(
b'#!/usr/bin/env python\n'
b'x = 1\n',
b'#!/usr/bin/env python\n'
b'# -*- coding: utf-8 -*-\n'
b'x = 1\n',
),
(
b'#coding=utf-8\n'
b'x = 1\n',
b'# -*- coding: utf-8 -*-\n'
b'x = 1\n',
),
(
b'#!/usr/bin/env python\n'
b'#coding=utf8\n'
b'x = 1\n',
b'#!/usr/bin/env python\n'
b'# -*- coding: utf-8 -*-\n'
b'x = 1\n',
),
# These should each get truncated
(b'#coding: utf-8\n', b''),
(b'# -*- coding: utf-8 -*-\n', b''),
(b'#!/usr/bin/env python\n', b''),
(b'#!/usr/bin/env python\n#coding: utf8\n', b''),
(b'#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n', b''),
),
)
def test_not_ok_inputs(input_str, output):
bytesio = io.BytesIO(input_str)
assert fix_encoding_pragma(bytesio) == 1
bytesio.seek(0)
assert bytesio.read() == output
def test_ok_input_alternate_pragma():
input_s = b'# coding: utf-8\nx = 1\n'
bytesio = io.BytesIO(input_s)
ret = fix_encoding_pragma(bytesio, expected_pragma=b'# coding: utf-8')
assert ret == 0
bytesio.seek(0)
assert bytesio.read() == input_s
def test_not_ok_input_alternate_pragma():
bytesio = io.BytesIO(b'x = 1\n')
ret = fix_encoding_pragma(bytesio, expected_pragma=b'# coding: utf-8')
assert ret == 1
bytesio.seek(0)
assert bytesio.read() == b'# coding: utf-8\nx = 1\n'
@pytest.mark.parametrize(
('input_s', 'expected'),
(
('# coding: utf-8', b'# coding: utf-8'),
# trailing whitespace
('# coding: utf-8\n', b'# coding: utf-8'),
),
)
def test_normalize_pragma(input_s, expected):
assert _normalize_pragma(input_s) == expected
def test_integration_alternate_pragma(tmpdir, capsys):
f = tmpdir.join('f.py')
f.write('x = 1\n')
pragma = '# coding: utf-8'
assert main((f.strpath, '--pragma', pragma)) == 1
assert f.read() == '# coding: utf-8\nx = 1\n'
out, _ = capsys.readouterr()
assert out == f'Added `# coding: utf-8` to {f.strpath}\n'
def test_crlf_ok(tmpdir):
f = tmpdir.join('f.py')
f.write_binary(b'# -*- coding: utf-8 -*-\r\nx = 1\r\n')
assert not main((f.strpath,))
def test_crfl_adds(tmpdir):
f = tmpdir.join('f.py')
f.write_binary(b'x = 1\r\n')
assert main((f.strpath,))
assert f.read_binary() == b'# -*- coding: utf-8 -*-\r\nx = 1\r\n'

View file

@ -1,22 +1,22 @@
from __future__ import annotations
import os
import subprocess
from unittest import mock
import pytest
from pre_commit_hooks.forbid_new_submodules import main
from testing.util import git_commit
@pytest.fixture
def git_dir_with_git_dir(tmpdir):
with tmpdir.as_cwd():
subprocess.check_call(('git', 'init', '.'))
subprocess.check_call((
'git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign',
))
git_commit('--allow-empty', '-m', 'init')
subprocess.check_call(('git', 'init', 'foo'))
subprocess.check_call(
('git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign'),
cwd=tmpdir.join('foo').strpath,
)
git_commit('--allow-empty', '-m', 'init', cwd=str(tmpdir.join('foo')))
yield
@ -31,7 +31,24 @@ def git_dir_with_git_dir(tmpdir):
)
def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
subprocess.check_call(cmd)
assert main() == 1
assert main(('random_non-related_file',)) == 0
assert main(('foo',)) == 1
out, _ = capsys.readouterr()
assert out.startswith('foo: new submodule introduced\n')
def test_main_new_submodule_committed(git_dir_with_git_dir, capsys):
rev_parse_cmd = ('git', 'rev-parse', 'HEAD')
from_ref = subprocess.check_output(rev_parse_cmd).decode().strip()
subprocess.check_call(('git', 'submodule', 'add', './foo'))
git_commit('-m', 'new submodule')
to_ref = subprocess.check_output(rev_parse_cmd).decode().strip()
with mock.patch.dict(
os.environ,
{'PRE_COMMIT_FROM_REF': from_ref, 'PRE_COMMIT_TO_REF': to_ref},
):
assert main(('random_non-related_file',)) == 0
assert main(('foo',)) == 1
out, _ = capsys.readouterr()
assert out.startswith('foo: new submodule introduced\n')
@ -39,4 +56,4 @@ def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
def test_main_no_new_submodule(git_dir_with_git_dir):
open('test.py', 'a+').close()
subprocess.check_call(('git', 'add', 'test.py'))
assert main() == 0
assert main(('test.py',)) == 0

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.mixed_line_ending import main
@ -25,7 +27,7 @@ from pre_commit_hooks.mixed_line_ending import main
def test_mixed_line_ending_fixes_auto(input_s, output, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
ret = main((path.strpath,))
ret = main((str(path),))
assert ret == 1
assert path.read_binary() == output
@ -34,7 +36,7 @@ def test_mixed_line_ending_fixes_auto(input_s, output, tmpdir):
def test_non_mixed_no_newline_end_of_file(tmpdir):
path = tmpdir.join('f.txt')
path.write_binary(b'foo\nbar\nbaz')
assert not main((path.strpath,))
assert not main((str(path),))
# the hook *could* fix the end of the file, but leaves it alone
# this is mostly to document the current behaviour
assert path.read_binary() == b'foo\nbar\nbaz'
@ -43,7 +45,7 @@ def test_non_mixed_no_newline_end_of_file(tmpdir):
def test_mixed_no_newline_end_of_file(tmpdir):
path = tmpdir.join('f.txt')
path.write_binary(b'foo\r\nbar\nbaz')
assert main((path.strpath,))
assert main((str(path),))
# the hook rewrites the end of the file, this is slightly inconsistent
# with the non-mixed case but I think this is the better behaviour
# this is mostly to document the current behaviour
@ -66,7 +68,7 @@ def test_mixed_no_newline_end_of_file(tmpdir):
def test_line_endings_ok(fix_option, input_s, tmpdir, capsys):
path = tmpdir.join('input.txt')
path.write_binary(input_s)
ret = main((fix_option, path.strpath))
ret = main((fix_option, str(path)))
assert ret == 0
assert path.read_binary() == input_s
@ -78,7 +80,7 @@ def test_no_fix_does_not_modify(tmpdir, capsys):
path = tmpdir.join('input.txt')
contents = b'foo\r\nbar\rbaz\nwomp\n'
path.write_binary(contents)
ret = main(('--fix=no', path.strpath))
ret = main(('--fix=no', str(path)))
assert ret == 1
assert path.read_binary() == contents
@ -89,7 +91,7 @@ def test_no_fix_does_not_modify(tmpdir, capsys):
def test_fix_lf(tmpdir, capsys):
path = tmpdir.join('input.txt')
path.write_binary(b'foo\r\nbar\rbaz\n')
ret = main(('--fix=lf', path.strpath))
ret = main(('--fix=lf', str(path)))
assert ret == 1
assert path.read_binary() == b'foo\nbar\nbaz\n'
@ -100,7 +102,7 @@ def test_fix_lf(tmpdir, capsys):
def test_fix_crlf(tmpdir):
path = tmpdir.join('input.txt')
path.write_binary(b'foo\r\nbar\rbaz\n')
ret = main(('--fix=crlf', path.strpath))
ret = main(('--fix=crlf', str(path)))
assert ret == 1
assert path.read_binary() == b'foo\r\nbar\r\nbaz\r\n'
@ -110,7 +112,7 @@ def test_fix_lf_all_crlf(tmpdir):
"""Regression test for #239"""
path = tmpdir.join('input.txt')
path.write_binary(b'foo\r\nbar\r\n')
ret = main(('--fix=lf', path.strpath))
ret = main(('--fix=lf', str(path)))
assert ret == 1
assert path.read_binary() == b'foo\nbar\n'

View file

@ -1,20 +1,23 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.no_commit_to_branch import is_on_branch
from pre_commit_hooks.no_commit_to_branch import main
from pre_commit_hooks.util import cmd_output
from testing.util import git_commit
def test_other_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', 'anotherbranch')
assert is_on_branch({'master'}) is False
assert is_on_branch({'placeholder'}) is False
def test_multi_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', 'another/branch')
assert is_on_branch({'master'}) is False
assert is_on_branch({'placeholder'}) is False
def test_multi_branch_fail(temp_git_dir):
@ -23,9 +26,10 @@ def test_multi_branch_fail(temp_git_dir):
assert is_on_branch({'another/branch'}) is True
def test_master_branch(temp_git_dir):
def test_exact_branch(temp_git_dir):
with temp_git_dir.as_cwd():
assert is_on_branch({'master'}) is True
cmd_output('git', 'checkout', '-b', 'branchname')
assert is_on_branch({'branchname'}) is True
def test_main_branch_call(temp_git_dir):
@ -47,11 +51,11 @@ def test_branch_pattern_fail(temp_git_dir):
assert is_on_branch(set(), {'another/.*'}) is True
@pytest.mark.parametrize('branch_name', ('master', 'another/branch'))
@pytest.mark.parametrize('branch_name', ('somebranch', 'another/branch'))
def test_branch_pattern_multiple_branches_fail(temp_git_dir, branch_name):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', branch_name)
assert main(('--branch', 'master', '--pattern', 'another/.*'))
assert main(('--branch', 'somebranch', '--pattern', 'another/.*'))
def test_main_default_call(temp_git_dir):
@ -62,8 +66,15 @@ def test_main_default_call(temp_git_dir):
def test_not_on_a_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'commit', '--no-gpg-sign', '--allow-empty', '-m1')
git_commit('--allow-empty', '-m1')
head = cmd_output('git', 'rev-parse', 'HEAD').strip()
cmd_output('git', 'checkout', head)
# we're not on a branch!
assert main(()) == 0
@pytest.mark.parametrize('branch_name', ('master', 'main'))
def test_default_branch_names(temp_git_dir, branch_name):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', branch_name)
assert main(()) == 1

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import os
import shutil
@ -67,19 +69,37 @@ def test_autofix_main(tmpdir):
srcfile = tmpdir.join('to_be_json_formatted.json')
shutil.copyfile(
get_resource_path('not_pretty_formatted_json.json'),
srcfile.strpath,
str(srcfile),
)
# now launch the autofix on that file
ret = main(['--autofix', srcfile.strpath])
ret = main(['--autofix', str(srcfile)])
# it should have formatted it
assert ret == 1
# file was formatted (shouldn't trigger linter again)
ret = main([srcfile.strpath])
ret = main([str(srcfile)])
assert ret == 0
def test_invalid_main(tmpdir):
srcfile1 = tmpdir.join('not_valid_json.json')
srcfile1.write(
'{\n'
' // not json\n'
' "a": "b"\n'
'}',
)
srcfile2 = tmpdir.join('to_be_json_formatted.json')
srcfile2.write('{ "a": "b" }')
# it should have skipped the first file and formatted the second one
assert main(['--autofix', str(srcfile1), str(srcfile2)]) == 1
# confirm second file was formatted (shouldn't trigger linter again)
assert main([str(srcfile2)]) == 0
def test_orderfile_get_pretty_format():
ret = main((
'--top-keys=alist', get_resource_path('pretty_formatted_json.json'),

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from pre_commit_hooks.check_yaml import yaml

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.removed import main

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.requirements_txt_fixer import FAIL
@ -30,6 +32,16 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
),
(b'#comment\n\nfoo\nbar\n', FAIL, b'#comment\n\nbar\nfoo\n'),
(b'#comment\n\nbar\nfoo\n', PASS, b'#comment\n\nbar\nfoo\n'),
(
b'foo\n\t#comment with indent\nbar\n',
FAIL,
b'\t#comment with indent\nbar\nfoo\n',
),
(
b'bar\n\t#comment with indent\nfoo\n',
PASS,
b'bar\n\t#comment with indent\nfoo\n',
),
(b'\nfoo\nbar\n', FAIL, b'bar\n\nfoo\n'),
(b'\nbar\nfoo\n', PASS, b'\nbar\nfoo\n'),
(
@ -56,6 +68,12 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
b'f<=2\n'
b'g<2\n',
),
(b'a==1\nb==1\na==1\n', FAIL, b'a==1\nb==1\n'),
(
b'a==1\nb==1\n#comment about a\na==1\n',
FAIL,
b'#comment about a\na==1\nb==1\n',
),
(b'ocflib\nDjango\nPyMySQL\n', FAIL, b'Django\nocflib\nPyMySQL\n'),
(
b'-e git+ssh://git_url@tag#egg=ocflib\nDjango\nPyMySQL\n',
@ -64,6 +82,8 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
),
(b'bar\npkg-resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'),
(b'foo\npkg-resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'),
(b'bar\npkg_resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'),
(b'foo\npkg_resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'),
(
b'git+ssh://git_url@tag#egg=ocflib\nDjango\nijk\n',
FAIL,
@ -93,7 +113,7 @@ def test_integration(input_s, expected_retval, output, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
output_retval = main([path.strpath])
output_retval = main([str(path)])
assert path.read_binary() == output
assert output_retval == expected_retval

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import os
import pytest
@ -39,7 +41,7 @@ TEST_SORTS = [
@pytest.mark.parametrize('bad_lines,good_lines,retval', TEST_SORTS)
def test_integration_good_bad_lines(tmpdir, bad_lines, good_lines, retval):
file_path = os.path.join(tmpdir.strpath, 'foo.yaml')
file_path = os.path.join(str(tmpdir), 'foo.yaml')
with open(file_path, 'w') as f:
f.write('\n'.join(bad_lines) + '\n')

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap
import pytest
@ -35,6 +37,12 @@ TESTS = (
1,
),
('"foo""bar"', "'foo''bar'", 1),
pytest.param(
"f'hello{\"world\"}'",
"f'hello{\"world\"}'",
0,
id='ignore nested fstrings',
),
)
@ -42,7 +50,7 @@ TESTS = (
def test_rewrite(input_s, output, expected_retval, tmpdir):
path = tmpdir.join('file.py')
path.write(input_s)
retval = main([path.strpath])
retval = main([str(path)])
assert path.read() == output
assert retval == expected_retval
@ -50,5 +58,5 @@ def test_rewrite(input_s, output, expected_retval, tmpdir):
def test_rewrite_crlf(tmpdir):
f = tmpdir.join('f.py')
f.write_binary(b'"foo"\r\n"bar"\r\n')
assert main((f.strpath,))
assert main((str(f),))
assert f.read_binary() == b"'foo'\r\n'bar'\r\n"

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from pre_commit_hooks.tests_should_end_in_test import main
@ -41,3 +43,8 @@ def test_main_not_django_fails():
def test_main_django_fails():
ret = main(['--django', 'foo_test.py', 'test_bar.py', 'test_baz.py'])
assert ret == 1
def test_main_pytest_test_first():
assert main(['--pytest-test-first', 'test_foo.py']) == 0
assert main(['--pytest-test-first', 'foo_test.py']) == 1

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.trailing_whitespace_fixer import main
@ -13,14 +15,14 @@ from pre_commit_hooks.trailing_whitespace_fixer import main
def test_fixes_trailing_whitespace(input_s, expected, tmpdir):
path = tmpdir.join('file.md')
path.write(input_s)
assert main((path.strpath,)) == 1
assert main((str(path),)) == 1
assert path.read() == expected
def test_ok_no_newline_end_of_file(tmpdir):
filename = tmpdir.join('f')
filename.write_binary(b'foo\nbar')
ret = main((filename.strpath,))
ret = main((str(filename),))
assert filename.read_binary() == b'foo\nbar'
assert ret == 0
@ -28,7 +30,7 @@ def test_ok_no_newline_end_of_file(tmpdir):
def test_ok_with_dos_line_endings(tmpdir):
filename = tmpdir.join('f')
filename.write_binary(b'foo\r\nbar\r\nbaz\r\n')
ret = main((filename.strpath,))
ret = main((str(filename),))
assert filename.read_binary() == b'foo\r\nbar\r\nbaz\r\n'
assert ret == 0
@ -43,7 +45,7 @@ def test_fixes_markdown_files(tmpdir, ext):
'\t\n' # trailing tabs are stripped anyway
'\n ', # whitespace at the end of the file is removed
)
ret = main((path.strpath, f'--markdown-linebreak-ext={ext}'))
ret = main((str(path), f'--markdown-linebreak-ext={ext}'))
assert ret == 1
assert path.read() == (
'foo \n'
@ -63,7 +65,7 @@ def test_markdown_linebreak_ext_badopt(arg):
def test_prints_warning_with_no_markdown_ext(capsys, tmpdir):
f = tmpdir.join('f').ensure()
assert main((f.strpath, '--no-markdown-linebreak-ext')) == 0
assert main((str(f), '--no-markdown-linebreak-ext')) == 0
out, _ = capsys.readouterr()
assert out == '--no-markdown-linebreak-ext now does nothing!\n'
@ -72,7 +74,7 @@ def test_preserve_non_utf8_file(tmpdir):
non_utf8_bytes_content = b'<a>\xe9 \n</a>\n'
path = tmpdir.join('file.txt')
path.write_binary(non_utf8_bytes_content)
ret = main([path.strpath])
ret = main([str(path)])
assert ret == 1
assert path.size() == (len(non_utf8_bytes_content) - 1)
@ -81,7 +83,7 @@ def test_custom_charset_change(tmpdir):
# strip spaces only, no tabs
path = tmpdir.join('file.txt')
path.write('\ta \t \n')
ret = main([path.strpath, '--chars', ' '])
ret = main([str(path), '--chars', ' '])
assert ret == 1
assert path.read() == '\ta \t\n'
@ -89,13 +91,13 @@ def test_custom_charset_change(tmpdir):
def test_custom_charset_no_change(tmpdir):
path = tmpdir.join('file.txt')
path.write('\ta \t\n')
ret = main([path.strpath, '--chars', ' '])
ret = main([str(path), '--chars', ' '])
assert ret == 0
def test_markdown_with_custom_charset(tmpdir):
path = tmpdir.join('file.md')
path.write('\ta \t \n')
ret = main([path.strpath, '--chars', ' ', '--markdown-linebreak-ext', '*'])
ret = main([str(path), '--chars', ' ', '--markdown-linebreak-ext', '*'])
assert ret == 1
assert path.read() == '\ta \t \n'

View file

@ -1,7 +1,10 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.util import CalledProcessError
from pre_commit_hooks.util import cmd_output
from pre_commit_hooks.util import zsplit
def test_raises_on_error():
@ -12,3 +15,13 @@ def test_raises_on_error():
def test_output():
ret = cmd_output('sh', '-c', 'echo hi')
assert ret == 'hi\n'
@pytest.mark.parametrize('out', ('\0f1\0f2\0', '\0f1\0f2', 'f1\0f2\0'))
def test_check_zsplits_str_correctly(out):
assert zsplit(out) == ['f1', 'f2']
@pytest.mark.parametrize('out', ('\0\0', '\0', ''))
def test_check_zsplit_returns_empty(out):
assert zsplit(out) == []

View file

@ -1,5 +1,5 @@
[tox]
envlist = py36,py37,py38,pypy3,pre-commit
envlist = py,pre-commit
[testenv]
deps = -rrequirements-dev.txt
@ -11,8 +11,7 @@ setenv =
commands =
coverage erase
coverage run -m pytest {posargs:tests}
coverage report --fail-under 100
pre-commit install
coverage report
[testenv:pre-commit]
skip_install = true