mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
upgrade hooks, pyupgrade pre-commit
This commit is contained in:
parent
764c765d29
commit
30c1e8289f
91 changed files with 176 additions and 437 deletions
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import collections
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
|
|
@ -58,10 +54,10 @@ def modify_manifest(path, commit=True):
|
|||
.pre-commit-hooks.yaml.
|
||||
"""
|
||||
manifest_path = os.path.join(path, C.MANIFEST_FILE)
|
||||
with io.open(manifest_path) as f:
|
||||
with open(manifest_path) as f:
|
||||
manifest = ordered_load(f.read())
|
||||
yield manifest
|
||||
with io.open(manifest_path, 'w') as manifest_file:
|
||||
with open(manifest_path, 'w') as manifest_file:
|
||||
manifest_file.write(ordered_dump(manifest, **C.YAML_DUMP_KWARGS))
|
||||
if commit:
|
||||
git_commit(msg=modify_manifest.__name__, cwd=path)
|
||||
|
|
@ -73,10 +69,10 @@ def modify_config(path='.', commit=True):
|
|||
.pre-commit-config.yaml
|
||||
"""
|
||||
config_path = os.path.join(path, C.CONFIG_FILE)
|
||||
with io.open(config_path) as f:
|
||||
with open(config_path) as f:
|
||||
config = ordered_load(f.read())
|
||||
yield config
|
||||
with io.open(config_path, 'w', encoding='UTF-8') as config_file:
|
||||
with open(config_path, 'w', encoding='UTF-8') as config_file:
|
||||
config_file.write(ordered_dump(config, **C.YAML_DUMP_KWARGS))
|
||||
if commit:
|
||||
git_commit(msg=modify_config.__name__, cwd=path)
|
||||
|
|
@ -101,7 +97,7 @@ def sample_meta_config():
|
|||
def make_config_from_repo(repo_path, rev=None, hooks=None, check=True):
|
||||
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
|
||||
config = {
|
||||
'repo': 'file://{}'.format(repo_path),
|
||||
'repo': f'file://{repo_path}',
|
||||
'rev': rev or git.head_rev(repo_path),
|
||||
'hooks': hooks or [{'id': hook['id']} for hook in manifest],
|
||||
}
|
||||
|
|
@ -117,7 +113,7 @@ def make_config_from_repo(repo_path, rev=None, hooks=None, check=True):
|
|||
|
||||
def read_config(directory, config_file=C.CONFIG_FILE):
|
||||
config_path = os.path.join(directory, config_file)
|
||||
with io.open(config_path) as f:
|
||||
with open(config_path) as f:
|
||||
config = ordered_load(f.read())
|
||||
return config
|
||||
|
||||
|
|
@ -126,7 +122,7 @@ def write_config(directory, config, config_file=C.CONFIG_FILE):
|
|||
if type(config) is not list and 'repos' not in config:
|
||||
assert isinstance(config, dict), config
|
||||
config = {'repos': [config]}
|
||||
with io.open(os.path.join(directory, config_file), 'w') as outfile:
|
||||
with open(os.path.join(directory, config_file), 'w') as outfile:
|
||||
outfile.write(ordered_dump(config, **C.YAML_DUMP_KWARGS))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import sys
|
|||
def main():
|
||||
for i in range(6):
|
||||
f = sys.stdout if i % 2 == 0 else sys.stderr
|
||||
f.write('{}\n'.format(i))
|
||||
f.write(f'{i}\n')
|
||||
f.flush()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import contextlib
|
||||
import os.path
|
||||
import subprocess
|
||||
|
|
@ -50,7 +48,7 @@ def broken_deep_listdir(): # pragma: no cover (platform specific)
|
|||
if sys.platform != 'win32':
|
||||
return False
|
||||
try:
|
||||
os.listdir(str('\\\\?\\') + os.path.abspath(str('.')))
|
||||
os.listdir('\\\\?\\' + os.path.abspath('.'))
|
||||
except OSError:
|
||||
return True
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue