Skip to content

Commit a23cc57

Browse files
Merge branch 'main' into empty-object-with-newline
2 parents 39f95cc + 31903ea commit a23cc57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+318
-94
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ on:
88

99
jobs:
1010
main-windows:
11-
uses: asottile/workflows/.github/workflows/tox.yml@v1.5.0
11+
uses: asottile/workflows/.github/workflows/tox.yml@v1.8.1
1212
with:
13-
env: '["py38"]'
13+
env: '["py39"]'
1414
os: windows-latest
1515
main-linux:
16-
uses: asottile/workflows/.github/workflows/tox.yml@v1.5.0
16+
uses: asottile/workflows/.github/workflows/tox.yml@v1.8.1
1717
with:
18-
env: '["py38", "py39", "py310", "py311"]'
18+
env: '["py39", "py310", "py311", "py312"]'
1919
os: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -10,33 +10,32 @@ repos:
1010
- id: name-tests-test
1111
- id: requirements-txt-fixer
1212
- repo: https://github.com/asottile/setup-cfg-fmt
13-
rev: v2.4.0
13+
rev: v2.7.0
1414
hooks:
1515
- id: setup-cfg-fmt
1616
- repo: https://github.com/asottile/reorder-python-imports
17-
rev: v3.10.0
17+
rev: v3.14.0
1818
hooks:
1919
- id: reorder-python-imports
20-
args: [--py38-plus, --add-import, 'from __future__ import annotations']
20+
args: [--py39-plus, --add-import, 'from __future__ import annotations']
2121
- repo: https://github.com/asottile/add-trailing-comma
22-
rev: v3.0.1
22+
rev: v3.1.0
2323
hooks:
2424
- id: add-trailing-comma
2525
- repo: https://github.com/asottile/pyupgrade
26-
rev: v3.10.1
26+
rev: v3.19.1
2727
hooks:
2828
- id: pyupgrade
29-
args: [--py38-plus]
30-
- repo: https://github.com/pre-commit/mirrors-autopep8
31-
rev: v2.0.2
29+
args: [--py39-plus]
30+
- repo: https://github.com/hhatto/autopep8
31+
rev: v2.3.2
3232
hooks:
3333
- id: autopep8
3434
- repo: https://github.com/PyCQA/flake8
35-
rev: 6.1.0
35+
rev: 7.1.2
3636
hooks:
3737
- id: flake8
3838
- repo: https://github.com/pre-commit/mirrors-mypy
39-
rev: v1.4.1
39+
rev: v1.15.0
4040
hooks:
4141
- id: mypy
42-
additional_dependencies: [types-all]

.pre-commit-hooks.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
description: prevents giant files from being committed.
44
entry: check-added-large-files
55
language: python
6-
stages: [commit, push, manual]
6+
stages: [pre-commit, pre-push, manual]
7+
minimum_pre_commit_version: 3.2.0
78
- id: check-ast
89
name: check python ast
910
description: simply checks whether the files parse as valid python.
@@ -39,7 +40,13 @@
3940
entry: check-executables-have-shebangs
4041
language: python
4142
types: [text, executable]
42-
stages: [commit, push, manual]
43+
stages: [pre-commit, pre-push, manual]
44+
minimum_pre_commit_version: 3.2.0
45+
- id: check-illegal-windows-names
46+
name: check illegal windows names
47+
entry: Illegal Windows filenames detected
48+
language: fail
49+
files: '(?i)((^|/)(CON|PRN|AUX|NUL|COM[\d¹²³]|LPT[\d¹²³])(\.|/|$)|[<>:\"\\|?*\x00-\x1F]|/[^/]*[\.\s]/|[^/]*[\.\s]$)'
4350
- id: check-json
4451
name: check json
4552
description: checks json files for parseable syntax.
@@ -52,7 +59,8 @@
5259
entry: check-shebang-scripts-are-executable
5360
language: python
5461
types: [text]
55-
stages: [commit, push, manual]
62+
stages: [pre-commit, pre-push, manual]
63+
minimum_pre_commit_version: 3.2.0
5664
- id: pretty-format-json
5765
name: pretty format json
5866
description: sets a standard for formatting json files.
@@ -107,6 +115,7 @@
107115
entry: destroyed-symlinks
108116
language: python
109117
types: [file]
118+
stages: [pre-commit, pre-push, manual]
110119
- id: detect-aws-credentials
111120
name: detect aws credentials
112121
description: detects *your* aws credentials from the aws cli credentials file.
@@ -131,7 +140,8 @@
131140
entry: end-of-file-fixer
132141
language: python
133142
types: [text]
134-
stages: [commit, push, manual]
143+
stages: [pre-commit, pre-push, manual]
144+
minimum_pre_commit_version: 3.2.0
135145
- id: file-contents-sorter
136146
name: file contents sorter
137147
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.
@@ -145,7 +155,7 @@
145155
language: python
146156
types: [text]
147157
- id: fix-encoding-pragma
148-
name: fix python encoding pragma
158+
name: fix python encoding pragma (deprecated)
149159
description: 'adds # -*- coding: utf-8 -*- to the top of python files.'
150160
language: python
151161
entry: fix-encoding-pragma
@@ -198,4 +208,5 @@
198208
entry: trailing-whitespace-fixer
199209
language: python
200210
types: [text]
201-
stages: [commit, push, manual]
211+
stages: [pre-commit, pre-push, manual]
212+
minimum_pre_commit_version: 3.2.0

CHANGELOG.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,65 @@
1+
5.0.0 - 2024-10-05
2+
==================
3+
4+
### Features
5+
- `requirements-txt-fixer`: also remove `pkg_resources==...`.
6+
- #850 PR by @ericfrederich.
7+
- #1030 issue by @ericfrederich.
8+
- `check-illegal-windows-names`: new hook!
9+
- #1044 PR by @ericfrederich.
10+
- #589 issue by @ericfrederich.
11+
- #1049 PR by @Jeffrey-Lim.
12+
- `pretty-format-json`: continue processing even if a file has a json error.
13+
- #1039 PR by @amarvin.
14+
- #1038 issue by @amarvin.
15+
16+
### Fixes
17+
- `destroyed-symlinks`: set `stages` to `[pre-commit, pre-push, manual]`
18+
- PR #1085 by @AdrianDC.
19+
20+
### Migrating
21+
- pre-commit-hooks now requires `pre-commit>=3.2.0`.
22+
- use non-deprecated names for `stages`.
23+
- #1093 PR by @asottile.
24+
25+
4.6.0 - 2024-04-06
26+
==================
27+
28+
### Features
29+
- `requirements-txt-fixer`: remove duplicate packages.
30+
- #1014 PR by @vhoulbreque-withings.
31+
- #960 issue @csibe17.
32+
33+
### Migrating
34+
- `fix-encoding-pragma`: deprecated -- will be removed in 5.0.0. use
35+
[pyupgrade](https://github.com/asottile/pyupgrade) or some other tool.
36+
- #1033 PR by @mxr.
37+
- #1032 issue by @mxr.
38+
39+
4.5.0 - 2023-10-07
40+
==================
41+
42+
### Features
43+
- `requirements-txt-fixer`: also sort `constraints.txt` by default.
44+
- #857 PR by @lev-blit.
45+
- #830 issue by @PLPeeters.
46+
- `debug-statements`: add `bpdb` debugger.
47+
- #942 PR by @mwip.
48+
- #941 issue by @mwip.
49+
50+
### Fixes
51+
- `file-contents-sorter`: fix sorting an empty file.
52+
- #944 PR by @RoelAdriaans.
53+
- #935 issue by @paduszyk.
54+
- `double-quote-string-fixer`: don't rewrite inside f-strings in 3.12+.
55+
- #973 PR by @asottile.
56+
- #971 issue by @XuehaiPan.
57+
58+
## Migrating
59+
- now requires python >= 3.8.
60+
- #926 PR by @asottile.
61+
- #927 PR by @asottile.
62+
163
4.4.0 - 2022-11-23
264
==================
365

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Add this to your `.pre-commit-config.yaml`
1515

1616
```yaml
1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v4.4.0 # Use the ref you want to point at
18+
rev: v5.0.0 # Use the ref you want to point at
1919
hooks:
2020
- id: trailing-whitespace
2121
# - id: ...
@@ -51,6 +51,9 @@ Checks for a common error of placing code before the docstring.
5151
#### `check-executables-have-shebangs`
5252
Checks that non-binary executables have a proper shebang.
5353

54+
#### `check-illegal-windows-names`
55+
Check for files that cannot be created on Windows.
56+
5457
#### `check-json`
5558
Attempts to load all json files to verify syntax.
5659

@@ -117,6 +120,7 @@ Makes sure files end in a newline and only a newline.
117120
Sort the lines in specified files (defaults to alphabetical).
118121
You must provide the target [`files`](https://pre-commit.com/#config-files) as input.
119122
Note that this hook WILL remove blank lines and does NOT respect any comments.
123+
All newlines will be converted to line feeds (`\n`).
120124

121125
The following arguments are available:
122126
- `--ignore-case` - fold lower case to upper case characters.
@@ -126,6 +130,9 @@ The following arguments are available:
126130
removes UTF-8 byte order marker
127131

128132
#### `fix-encoding-pragma`
133+
134+
_Deprecated since py2 is EOL - use [pyupgrade](https://github.com/asottile/pyupgrade) instead._
135+
129136
Add `# -*- coding: utf-8 -*-` to the top of python files.
130137
- To remove the coding pragma pass `--remove` (useful in a python3-only codebase)
131138

pre_commit_hooks/check_added_large_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import math
55
import os
66
import subprocess
7-
from typing import Sequence
7+
from collections.abc import Sequence
88

99
from pre_commit_hooks.util import added_files
1010
from pre_commit_hooks.util import zsplit
@@ -46,7 +46,7 @@ def find_large_added_files(
4646
filenames_filtered &= added_files()
4747

4848
for filename in filenames_filtered:
49-
kb = int(math.ceil(os.stat(filename).st_size / 1024))
49+
kb = math.ceil(os.stat(filename).st_size / 1024)
5050
if kb > maxkb:
5151
print(f'{filename} ({kb} KB) exceeds {maxkb} KB.')
5252
retv = 1

pre_commit_hooks/check_ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import platform
66
import sys
77
import traceback
8-
from typing import Sequence
8+
from collections.abc import Sequence
99

1010

1111
def main(argv: Sequence[str] | None = None) -> int:

pre_commit_hooks/check_builtin_literals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import argparse
44
import ast
5+
from collections.abc import Sequence
56
from typing import NamedTuple
6-
from typing import Sequence
77

88

99
BUILTIN_TYPES = {

pre_commit_hooks/check_byte_order_marker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import argparse
4-
from typing import Sequence
4+
from collections.abc import Sequence
55

66

77
def main(argv: Sequence[str] | None = None) -> int:

pre_commit_hooks/check_case_conflict.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
22

33
import argparse
4-
from typing import Iterable
5-
from typing import Iterator
6-
from typing import Sequence
4+
from collections.abc import Iterable
5+
from collections.abc import Iterator
6+
from collections.abc import Sequence
77

88
from pre_commit_hooks.util import added_files
99
from pre_commit_hooks.util import cmd_output

0 commit comments

Comments
 (0)