Skip to content

Commit a4e3cfe

Browse files
authored
Improve pre-commit config (#9563)
- Add a few more hooks. These are all very fast, and I've found them useful in other projects: - Autofixes: - `trailing-whitespace`: fixes trailing whitespace - `requirements-txt-fixer`: alphabetises items in `requirements.txt` files - `end-of-file-fixer`: makes sure every file ends with a single newline character - `mixed-line-ending`: Makes sure Windows users don't accidentally introduce CRLF line endings into a file that uses LF line endings - None-autofixes: - `check-yaml`: loads YAML files to validate syntax - `check-toml`: loads TOML files to validate syntax - `check-merge-conflict`: detects merge-conflict strings in files and blocks them from accidentally being committed - `check-case-conflict`: checks for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT; blocks them from being committed. - Change the bot schedule to quarterly, to reduce noisy PRs - Change the `black` language target-version to Python 3.10, synching the setting here with the changes that were made to our `pyproject.toml` file in #7538
1 parent aa4d6d8 commit a4e3cfe

File tree

14 files changed

+30
-19
lines changed

14 files changed

+30
-19
lines changed

.pre-commit-config.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0 # must match requirements-tests.txt
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: requirements-txt-fixer
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
- id: check-toml
10+
- id: check-merge-conflict
11+
- id: mixed-line-ending
12+
- id: check-case-conflict
213
- repo: https://github.com/hadialqattan/pycln
314
rev: v2.1.3 # must match requirements-tests.txt
415
hooks:
@@ -8,7 +19,7 @@ repos:
819
rev: 22.12.0 # must match requirements-tests.txt
920
hooks:
1021
- id: black
11-
language_version: python3.9
22+
language_version: python3.10
1223
- repo: https://github.com/pycqa/isort
1324
rev: 5.11.4 # must match requirements-tests.txt
1425
hooks:
@@ -33,6 +44,6 @@ ci:
3344
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"
3445
autofix_prs: true
3546
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
36-
autoupdate_schedule: weekly
47+
autoupdate_schedule: quarterly
3748
skip: [flake8]
3849
submodules: false

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,3 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
235235
DEALINGS IN THE SOFTWARE.
236236

237237
= = = = =
238-

requirements-tests.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ isort==5.11.4 # must match .pre-commit-confi
88
mypy==0.991
99
packaging==23.0
1010
pathspec>=0.10.3
11+
pre-commit-hooks==4.4.0 # must match .pre-commit-config.yaml
1112
pycln==2.1.3 # must match .pre-commit-config.yaml
12-
pyyaml==6.0
1313
pytype==2023.1.17; platform_system != "Windows" and python_version < "3.11"
14+
pyyaml==6.0
1415
termcolor>=2
1516
tomli==2.0.1
1617
tomlkit==0.11.6

stubs/aiofiles/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ aiofiles.tempfile.AiofilesContextManagerTempDir
6363

6464
# Helper decorator, too complex to type
6565
aiofiles.os.wrap
66-

stubs/croniter/@tests/stubtest_allowlist.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
croniter.croniter.EXPANDERS
33
croniter.croniter.HashExpander
44
croniter.croniter.VALID_LEN_EXPRESSION
5-
croniter.croniter.timedelta_to_seconds
5+
croniter.croniter.timedelta_to_seconds

stubs/editdistance/METADATA.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ version = "0.6.*"
22

33
[tool.stubtest]
44
ignore_missing_stub = false
5-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
docutils
2-
mock
2+
mock
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
oauthlib.oauth1.rfc5849.parameters.prepare_headers
1+
oauthlib.oauth1.rfc5849.parameters.prepare_headers
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# "cls" argument has wrong name in implementation.
2-
openpyxl.descriptors.slots.AutoSlotProperties.__new__
2+
openpyxl.descriptors.slots.AutoSlotProperties.__new__

stubs/psycopg2/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "2.9.*"
1+
version = "2.9.*"

0 commit comments

Comments
 (0)