Skip to content

Commit b81c980

Browse files
committed
Remove py26 format literals
Resolves pre-commit#403
1 parent 26e60fa commit b81c980

28 files changed

+58
-58
lines changed

pre_commit/clientlib/validate_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ def get_validator(
3838
"""
3939
def validate(filename, load_strategy=yaml.load):
4040
if not os.path.exists(filename):
41-
raise exception_type('File {0} does not exist'.format(filename))
41+
raise exception_type('File {} does not exist'.format(filename))
4242

4343
file_contents = open(filename, 'r').read()
4444

4545
try:
4646
obj = load_strategy(file_contents)
4747
except Exception as e:
4848
raise exception_type(
49-
'Invalid yaml: {0}\n{1}'.format(os.path.relpath(filename), e),
49+
'Invalid yaml: {}\n{}'.format(os.path.relpath(filename), e),
5050
)
5151

5252
try:
5353
jsonschema.validate(obj, json_schema)
5454
except jsonschema.exceptions.ValidationError as e:
5555
raise exception_type(
56-
'Invalid content: {0}\n{1}'.format(
56+
'Invalid content: {}\n{}'.format(
5757
os.path.relpath(filename), e
5858
),
5959
)
@@ -75,7 +75,7 @@ def run(argv=None):
7575
parser.add_argument(
7676
'-V', '--version',
7777
action='version',
78-
version='%(prog)s {0}'.format(
78+
version='%(prog)s {}'.format(
7979
pkg_resources.get_distribution('pre-commit').version
8080
)
8181
)

pre_commit/clientlib/validate_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class InvalidConfigError(FatalError):
5757
def try_regex(repo, hook, value, field_name):
5858
if not is_regex_valid(value):
5959
raise InvalidConfigError(
60-
'Invalid {0} regex at {1}, {2}: {3}'.format(
60+
'Invalid {} regex at {}, {}: {}'.format(
6161
field_name, repo, hook, value,
6262
)
6363
)
@@ -72,7 +72,7 @@ def validate_config_extra(config):
7272
)
7373
elif 'sha' not in repo:
7474
raise InvalidConfigError(
75-
'Missing "sha" field for repository {0}'.format(repo['repo'])
75+
'Missing "sha" field for repository {}'.format(repo['repo'])
7676
)
7777
for hook in repo['hooks']:
7878
try_regex(repo, hook['id'], hook.get('files', ''), 'files')

pre_commit/clientlib/validate_manifest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class InvalidManifestError(ValueError):
5555
def validate_languages(hook_config):
5656
if hook_config['language'] not in all_languages:
5757
raise InvalidManifestError(
58-
'Expected language {0} for {1} to be one of {2!r}'.format(
58+
'Expected language {} for {} to be one of {!r}'.format(
5959
hook_config['id'],
6060
hook_config['language'],
6161
all_languages,
@@ -66,14 +66,14 @@ def validate_languages(hook_config):
6666
def validate_files(hook_config):
6767
if not is_regex_valid(hook_config['files']):
6868
raise InvalidManifestError(
69-
'Invalid files regex at {0}: {1}'.format(
69+
'Invalid files regex at {}: {}'.format(
7070
hook_config['id'], hook_config['files'],
7171
)
7272
)
7373

7474
if not is_regex_valid(hook_config.get('exclude', '')):
7575
raise InvalidManifestError(
76-
'Invalid exclude regex at {0}: {1}'.format(
76+
'Invalid exclude regex at {}: {}'.format(
7777
hook_config['id'], hook_config['exclude'],
7878
)
7979
)

pre_commit/color.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def format_color(text, color, use_color_setting):
2424
if not use_color_setting:
2525
return text
2626
else:
27-
return u'{0}{1}{2}'.format(color, text, NORMAL)
27+
return '{}{}{}'.format(color, text, NORMAL)
2828

2929

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

pre_commit/commands/autoupdate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _update_repository(repo_config, runner):
6161
if hooks_missing:
6262
raise RepositoryCannotBeUpdatedError(
6363
'Cannot update because the tip of master is missing these hooks:\n'
64-
'{0}'.format(', '.join(sorted(hooks_missing)))
64+
'{}'.format(', '.join(sorted(hooks_missing)))
6565
)
6666

6767
return new_config
@@ -86,7 +86,7 @@ def autoupdate(runner):
8686
if is_local_hooks(repo_config):
8787
output_configs.append(repo_config)
8888
continue
89-
sys.stdout.write('Updating {0}...'.format(repo_config['repo']))
89+
sys.stdout.write('Updating {}...'.format(repo_config['repo']))
9090
sys.stdout.flush()
9191
try:
9292
new_repo_config = _update_repository(repo_config, runner)
@@ -99,7 +99,7 @@ def autoupdate(runner):
9999
if new_repo_config['sha'] != repo_config['sha']:
100100
changed = True
101101
print(
102-
'updating {0} -> {1}.'.format(
102+
'updating {} -> {}.'.format(
103103
repo_config['sha'], new_repo_config['sha'],
104104
)
105105
)

pre_commit/commands/clean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
def clean(runner):
1010
if os.path.exists(runner.store.directory):
1111
rmtree(runner.store.directory)
12-
print('Cleaned {0}.'.format(runner.store.directory))
12+
print('Cleaned {}.'.format(runner.store.directory))
1313
return 0

pre_commit/commands/install_uninstall.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
6262
os.remove(legacy_path)
6363
elif os.path.exists(legacy_path):
6464
print(
65-
'Running in migration mode with existing hooks at {0}\n'
65+
'Running in migration mode with existing hooks at {}\n'
6666
'Use -f to use only pre-commit.'.format(
6767
legacy_path,
6868
)
@@ -83,7 +83,7 @@ def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
8383
pre_commit_file_obj.write(contents)
8484
make_executable(hook_path)
8585

86-
print('pre-commit installed at {0}'.format(hook_path))
86+
print('pre-commit installed at {}'.format(hook_path))
8787

8888
# If they requested we install all of the hooks, do so.
8989
if hooks:
@@ -110,10 +110,10 @@ def uninstall(runner, hook_type='pre-commit'):
110110
return 0
111111

112112
os.remove(hook_path)
113-
print('{0} uninstalled'.format(hook_type))
113+
print('{} uninstalled'.format(hook_type))
114114

115115
if os.path.exists(legacy_path):
116116
os.rename(legacy_path, hook_path)
117-
print('Restored previous hooks to {0}'.format(hook_path))
117+
print('Restored previous hooks to {}'.format(hook_path))
118118

119119
return 0

pre_commit/commands/run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def _get_skips(environ):
2424

2525

2626
def _hook_msg_start(hook, verbose):
27-
return '{0}{1}'.format(
28-
'[{0}] '.format(hook['id']) if verbose else '',
27+
return '{}{}'.format(
28+
'[{}] '.format(hook['id']) if verbose else '',
2929
hook['name'],
3030
)
3131

@@ -51,7 +51,7 @@ def _print_user_skipped(hook, write, args):
5151

5252
def get_changed_files(new, old):
5353
return cmd_output(
54-
'git', 'diff', '--name-only', '{0}...{1}'.format(old, new),
54+
'git', 'diff', '--name-only', '{}...{}'.format(old, new),
5555
)[1].splitlines()
5656

5757

@@ -107,7 +107,7 @@ def _run_single_hook(hook, repo, args, write, skips=frozenset()):
107107
write(color.format_color(pass_fail, print_color, args.color) + '\n')
108108

109109
if (stdout or stderr or file_modifications) and (retcode or args.verbose):
110-
write('hookid: {0}\n'.format(hook['id']))
110+
write('hookid: {}\n'.format(hook['id']))
111111
write('\n')
112112

113113
# Print a message if failing due to file modifications
@@ -200,7 +200,7 @@ def run(runner, args, write=sys_stdout_write_wrapper, environ=os.environ):
200200
if hook['id'] == args.hook
201201
]
202202
if not repo_hooks:
203-
write('No hook with id `{0}`\n'.format(args.hook))
203+
write('No hook with id `{}`\n'.format(args.hook))
204204
return 1
205205

206206
# Filter hooks for stages

pre_commit/languages/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def environment_dir(ENVIRONMENT_DIR, language_version):
1111
if ENVIRONMENT_DIR is None:
1212
return None
1313
else:
14-
return '{0}-{1}'.format(ENVIRONMENT_DIR, language_version)
14+
return '{}-{}'.format(ENVIRONMENT_DIR, language_version)

pre_commit/languages/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def install_environment(
4747
with clean_path_on_failure(env_dir):
4848
cmd = [
4949
sys.executable, '-m', 'nodeenv', '--prebuilt',
50-
'{{prefix}}{0}'.format(directory),
50+
'{{prefix}}{}'.format(directory),
5151
]
5252

5353
if version != 'default':

0 commit comments

Comments
 (0)