upgrade hooks, pyupgrade pre-commit

This commit is contained in:
Anthony Sottile 2020-01-08 20:49:09 -08:00
parent 764c765d29
commit 30c1e8289f
91 changed files with 176 additions and 437 deletions

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python3
"""File generated by pre-commit: https://pre-commit.com"""
from __future__ import print_function
import distutils.spawn
import os
import subprocess
@ -64,7 +62,7 @@ def _run_legacy():
else:
stdin = None
legacy_hook = os.path.join(HERE, '{}.legacy'.format(HOOK_TYPE))
legacy_hook = os.path.join(HERE, f'{HOOK_TYPE}.legacy')
if os.access(legacy_hook, os.X_OK):
cmd = _norm_exe(legacy_hook) + (legacy_hook,) + tuple(sys.argv[1:])
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE if stdin else None)
@ -136,7 +134,7 @@ def _pre_push(stdin):
# ancestors not found in remote
ancestors = subprocess.check_output((
'git', 'rev-list', local_sha, '--topo-order', '--reverse',
'--not', '--remotes={}'.format(remote),
'--not', f'--remotes={remote}',
)).decode().strip()
if not ancestors:
continue
@ -148,7 +146,7 @@ def _pre_push(stdin):
# pushing the whole tree including root commit
opts = ('--all-files',)
else:
cmd = ('git', 'rev-parse', '{}^'.format(first_ancestor))
cmd = ('git', 'rev-parse', f'{first_ancestor}^')
source = subprocess.check_output(cmd).decode().strip()
opts = ('--origin', local_sha, '--source', source)