Skip to content

Commit 30c1e82

Browse files
committed
upgrade hooks, pyupgrade pre-commit
1 parent 764c765 commit 30c1e82

Some content is hidden

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

91 files changed

+176
-437
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 8 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: v2.1.0
3+
rev: v2.4.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -12,30 +12,36 @@ repos:
1212
- id: requirements-txt-fixer
1313
- id: double-quote-string-fixer
1414
- repo: https://gitlab.com/pycqa/flake8
15-
rev: 3.7.7
15+
rev: 3.7.9
1616
hooks:
1717
- id: flake8
1818
- repo: https://github.com/pre-commit/mirrors-autopep8
19-
rev: v1.4.3
19+
rev: v1.4.4
2020
hooks:
2121
- id: autopep8
2222
- repo: https://github.com/pre-commit/pre-commit
23-
rev: v1.14.4
23+
rev: v1.21.0
2424
hooks:
2525
- id: validate_manifest
2626
- repo: https://github.com/asottile/pyupgrade
27-
rev: v1.12.0
27+
rev: v1.25.3
2828
hooks:
2929
- id: pyupgrade
30+
args: [--py36-plus]
3031
- repo: https://github.com/asottile/reorder_python_imports
31-
rev: v1.4.0
32+
rev: v1.9.0
3233
hooks:
3334
- id: reorder-python-imports
34-
language_version: python3
35+
args: [--py3-plus]
3536
- repo: https://github.com/asottile/add-trailing-comma
36-
rev: v1.0.0
37+
rev: v1.5.0
3738
hooks:
3839
- id: add-trailing-comma
40+
args: [--py36-plus]
41+
- repo: https://github.com/asottile/setup-cfg-fmt
42+
rev: v1.6.0
43+
hooks:
44+
- id: setup-cfg-fmt
3945
- repo: meta
4046
hooks:
4147
- id: check-hooks-apply

azure-pipelines.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ resources:
1010
type: github
1111
endpoint: github
1212
name: asottile/azure-pipeline-templates
13-
ref: refs/tags/v0.0.15
13+
ref: refs/tags/v1.0.0
1414

1515
jobs:
1616
- template: job--pre-commit.yml@asottile
1717
- template: job--python-tox.yml@asottile
1818
parameters:
19-
toxenvs: [py27, py37]
19+
toxenvs: [py37]
2020
os: windows
2121
additional_variables:
2222
COVERAGE_IGNORE_WINDOWS: '# pragma: windows no cover'
2323
TOX_TESTENV_PASSENV: COVERAGE_IGNORE_WINDOWS
24-
TEMP: C:\Temp # remove when dropping python2
2524
pre_test:
2625
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
2726
displayName: Add conda to PATH
@@ -39,7 +38,7 @@ jobs:
3938
displayName: install swift
4039
- template: job--python-tox.yml@asottile
4140
parameters:
42-
toxenvs: [pypy, pypy3, py27, py36, py37, py38]
41+
toxenvs: [pypy3, py36, py37, py38]
4342
os: linux
4443
pre_test:
4544
- task: UseRubyVersion@0

pre_commit/__main__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from pre_commit.main import main
42

53

pre_commit/clientlib.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from __future__ import absolute_import
2-
from __future__ import unicode_literals
3-
41
import argparse
52
import functools
63
import logging
@@ -106,7 +103,7 @@ def validate_manifest_main(argv=None):
106103
META = 'meta'
107104

108105

109-
class MigrateShaToRev(object):
106+
class MigrateShaToRev:
110107
key = 'rev'
111108

112109
@staticmethod
@@ -202,7 +199,7 @@ def warn_unknown_keys_repo(extra, orig_keys, dct):
202199
if item.key in {'name', 'language', 'entry'} else
203200
item
204201
for item in MANIFEST_HOOK_DICT.items
205-
])
202+
]),
206203
)
207204
CONFIG_HOOK_DICT = cfgv.Map(
208205
'Hook', 'id',
@@ -217,7 +214,7 @@ def warn_unknown_keys_repo(extra, orig_keys, dct):
217214
cfgv.OptionalNoDefault(item.key, item.check_fn)
218215
for item in MANIFEST_HOOK_DICT.items
219216
if item.key != 'id'
220-
]
217+
],
221218
)
222219
CONFIG_REPO_DICT = cfgv.Map(
223220
'Repository', 'repo',
@@ -243,7 +240,7 @@ def warn_unknown_keys_repo(extra, orig_keys, dct):
243240
DEFAULT_LANGUAGE_VERSION = cfgv.Map(
244241
'DefaultLanguageVersion', None,
245242
cfgv.NoAdditionalKeys(all_languages),
246-
*[cfgv.Optional(x, cfgv.check_string, C.DEFAULT) for x in all_languages]
243+
*[cfgv.Optional(x, cfgv.check_string, C.DEFAULT) for x in all_languages],
247244
)
248245
CONFIG_SCHEMA = cfgv.Map(
249246
'Config', None,

pre_commit/color.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
import os
42
import sys
53

@@ -8,7 +6,7 @@
86
from pre_commit.color_windows import enable_virtual_terminal_processing
97
try:
108
enable_virtual_terminal_processing()
11-
except WindowsError:
9+
except OSError:
1210
terminal_supports_color = False
1311

1412
RED = '\033[41m'
@@ -34,7 +32,7 @@ def format_color(text, color, use_color_setting):
3432
if not use_color_setting:
3533
return text
3634
else:
37-
return '{}{}{}'.format(color, text, NORMAL)
35+
return f'{color}{text}{NORMAL}'
3836

3937

4038
COLOR_CHOICES = ('auto', 'always', 'never')

pre_commit/color_windows.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from __future__ import absolute_import
2-
from __future__ import unicode_literals
3-
41
from ctypes import POINTER
52
from ctypes import windll
63
from ctypes import WinError

pre_commit/commands/autoupdate.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
from __future__ import print_function
2-
from __future__ import unicode_literals
3-
41
import collections
52
import os.path
63
import re
74

8-
import six
95
from aspy.yaml import ordered_dump
106
from aspy.yaml import ordered_load
117

@@ -64,7 +60,7 @@ def _check_hooks_still_exist_at_rev(repo_config, info, store):
6460
path = store.clone(repo_config['repo'], info.rev)
6561
manifest = load_manifest(os.path.join(path, C.MANIFEST_FILE))
6662
except InvalidManifestError as e:
67-
raise RepositoryCannotBeUpdatedError(six.text_type(e))
63+
raise RepositoryCannotBeUpdatedError(str(e))
6864

6965
# See if any of our hooks were deleted with the new commits
7066
hooks = {hook['id'] for hook in repo_config['hooks']}
@@ -108,7 +104,7 @@ def _write_new_config(path, rev_infos):
108104
new_rev_s = ordered_dump({'rev': rev_info.rev}, **C.YAML_DUMP_KWARGS)
109105
new_rev = new_rev_s.split(':', 1)[1].strip()
110106
if rev_info.frozen is not None:
111-
comment = ' # frozen: {}'.format(rev_info.frozen)
107+
comment = f' # frozen: {rev_info.frozen}'
112108
elif match.group(4).strip().startswith('# frozen:'):
113109
comment = ''
114110
else:
@@ -138,7 +134,7 @@ def autoupdate(config_file, store, tags_only, freeze, repos=()):
138134
rev_infos.append(None)
139135
continue
140136

141-
output.write('Updating {} ... '.format(info.repo))
137+
output.write(f'Updating {info.repo} ... ')
142138
new_info = info.update(tags_only=tags_only, freeze=freeze)
143139
try:
144140
_check_hooks_still_exist_at_rev(repo_config, new_info, store)
@@ -151,10 +147,10 @@ def autoupdate(config_file, store, tags_only, freeze, repos=()):
151147
if new_info.rev != info.rev:
152148
changed = True
153149
if new_info.frozen:
154-
updated_to = '{} (frozen)'.format(new_info.frozen)
150+
updated_to = f'{new_info.frozen} (frozen)'
155151
else:
156152
updated_to = new_info.rev
157-
msg = 'updating {} -> {}.'.format(info.rev, updated_to)
153+
msg = f'updating {info.rev} -> {updated_to}.'
158154
output.write_line(msg)
159155
rev_infos.append(new_info)
160156
else:

pre_commit/commands/clean.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from __future__ import print_function
2-
from __future__ import unicode_literals
3-
41
import os.path
52

63
from pre_commit import output
@@ -12,5 +9,5 @@ def clean(store):
129
for directory in (store.directory, legacy_path):
1310
if os.path.exists(directory):
1411
rmtree(directory)
15-
output.write_line('Cleaned {}.'.format(directory))
12+
output.write_line(f'Cleaned {directory}.')
1613
return 0

pre_commit/commands/gc.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from __future__ import absolute_import
2-
from __future__ import unicode_literals
3-
41
import os.path
52

63
import pre_commit.constants as C
@@ -79,5 +76,5 @@ def _gc_repos(store):
7976
def gc(store):
8077
with store.exclusive_lock():
8178
repos_removed = _gc_repos(store)
82-
output.write_line('{} repo(s) removed.'.format(repos_removed))
79+
output.write_line(f'{repos_removed} repo(s) removed.')
8380
return 0

pre_commit/commands/init_templatedir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ def init_templatedir(config_file, store, directory, hook_types):
2323
if configured_path != dest:
2424
logger.warning('`init.templateDir` not set to the target directory')
2525
logger.warning(
26-
'maybe `git config --global init.templateDir {}`?'.format(dest),
26+
f'maybe `git config --global init.templateDir {dest}`?',
2727
)

0 commit comments

Comments
 (0)