mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-22 08:50:10 -06:00
Use asottile/add-trailing-comma
This commit is contained in:
@@ -20,18 +20,18 @@ def bool_errcheck(result, func, args):
|
||||
|
||||
GetStdHandle = WINFUNCTYPE(HANDLE, DWORD)(
|
||||
("GetStdHandle", windll.kernel32),
|
||||
((1, "nStdHandle"), )
|
||||
((1, "nStdHandle"), ),
|
||||
)
|
||||
|
||||
GetConsoleMode = WINFUNCTYPE(BOOL, HANDLE, POINTER(DWORD))(
|
||||
("GetConsoleMode", windll.kernel32),
|
||||
((1, "hConsoleHandle"), (2, "lpMode"))
|
||||
((1, "hConsoleHandle"), (2, "lpMode")),
|
||||
)
|
||||
GetConsoleMode.errcheck = bool_errcheck
|
||||
|
||||
SetConsoleMode = WINFUNCTYPE(BOOL, HANDLE, DWORD)(
|
||||
("SetConsoleMode", windll.kernel32),
|
||||
((1, "hConsoleHandle"), (1, "dwMode"))
|
||||
((1, "hConsoleHandle"), (1, "dwMode")),
|
||||
)
|
||||
SetConsoleMode.errcheck = bool_errcheck
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def _update_repo(repo_config, runner, tags_only):
|
||||
if hooks_missing:
|
||||
raise RepositoryCannotBeUpdatedError(
|
||||
'Cannot update because the tip of master is missing these hooks:\n'
|
||||
'{}'.format(', '.join(sorted(hooks_missing)))
|
||||
'{}'.format(', '.join(sorted(hooks_missing))),
|
||||
)
|
||||
|
||||
return new_config
|
||||
|
||||
@@ -51,7 +51,7 @@ def install(
|
||||
'Running in migration mode with existing hooks at {}\n'
|
||||
'Use -f to use only pre-commit.'.format(
|
||||
legacy_path,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
with io.open(hook_path, 'w') as pre_commit_file_obj:
|
||||
|
||||
@@ -235,7 +235,7 @@ def run(runner, args, environ=os.environ):
|
||||
logger.error(
|
||||
'Your .pre-commit-config.yaml is unstaged.\n'
|
||||
'`git add .pre-commit-config.yaml` to fix this.\n'
|
||||
'Run pre-commit with --allow-unstaged-config to silence this.'
|
||||
'Run pre-commit with --allow-unstaged-config to silence this.',
|
||||
)
|
||||
return 1
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def get_root():
|
||||
except CalledProcessError:
|
||||
raise FatalError(
|
||||
'git failed. Is it installed, and are you in a Git repository '
|
||||
'directory?'
|
||||
'directory?',
|
||||
)
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ def get_staged_files():
|
||||
return cmd_output(
|
||||
'git', 'diff', '--staged', '--name-only', '--no-ext-diff',
|
||||
# Everything except for D
|
||||
'--diff-filter=ACMRTUXB'
|
||||
'--diff-filter=ACMRTUXB',
|
||||
)[1].splitlines()
|
||||
|
||||
|
||||
@@ -130,5 +130,5 @@ def check_for_cygwin_mismatch():
|
||||
' - git {}\n'.format(
|
||||
exe_type[is_cygwin_python],
|
||||
exe_type[is_cygwin_git],
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ def md5(s): # pragma: windows no cover
|
||||
|
||||
def docker_tag(repo_cmd_runner): # pragma: windows no cover
|
||||
return 'pre-commit-{}'.format(
|
||||
md5(os.path.basename(repo_cmd_runner.path()))
|
||||
md5(os.path.basename(repo_cmd_runner.path())),
|
||||
).lower()
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ def run_hook(repo_cmd_runner, hook, file_args): # pragma: windows no cover
|
||||
'-v', '{}:/src:rw'.format(os.getcwd()),
|
||||
'--workdir', '/src',
|
||||
'--entrypoint', entry_executable,
|
||||
docker_tag(repo_cmd_runner)
|
||||
docker_tag(repo_cmd_runner),
|
||||
) + cmd_rest
|
||||
|
||||
return xargs(cmd, file_args)
|
||||
|
||||
@@ -107,7 +107,7 @@ def install_environment(repo_cmd_runner, version, additional_dependencies):
|
||||
with clean_path_on_failure(repo_cmd_runner.path(directory)):
|
||||
venv_cmd = [
|
||||
sys.executable, '-m', 'virtualenv',
|
||||
'{{prefix}}{}'.format(directory)
|
||||
'{{prefix}}{}'.format(directory),
|
||||
]
|
||||
if version != 'default':
|
||||
venv_cmd.extend(['-p', norm_version(version)])
|
||||
|
||||
@@ -81,7 +81,7 @@ def _install_rbenv(
|
||||
# directory
|
||||
"export GEM_HOME='{directory}/gems'\n"
|
||||
'export PATH="$GEM_HOME/bin:$PATH"\n'
|
||||
'\n'.format(directory=repo_cmd_runner.path(directory))
|
||||
'\n'.format(directory=repo_cmd_runner.path(directory)),
|
||||
)
|
||||
|
||||
# If we aren't using the system ruby, add a version here
|
||||
|
||||
@@ -30,7 +30,7 @@ class LoggingHandler(logging.Handler):
|
||||
self.use_color,
|
||||
) + ' ',
|
||||
record.getMessage(),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ def _add_color_option(parser):
|
||||
def _add_config_option(parser):
|
||||
parser.add_argument(
|
||||
'-c', '--config', default='.pre-commit-config.yaml',
|
||||
help='Path to alternate config file'
|
||||
help='Path to alternate config file',
|
||||
)
|
||||
|
||||
|
||||
@@ -228,11 +228,11 @@ def main(argv=None):
|
||||
return sample_config()
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
'Command {} not implemented.'.format(args.command)
|
||||
'Command {} not implemented.'.format(args.command),
|
||||
)
|
||||
|
||||
raise AssertionError(
|
||||
'Command {} failed to exit with a returncode'.format(args.command)
|
||||
'Command {} failed to exit with a returncode'.format(args.command),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ REPOS = (
|
||||
|
||||
|
||||
RESOURCES_DIR = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), 'resources')
|
||||
os.path.join(os.path.dirname(__file__), 'resources'),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class Manifest(object):
|
||||
'If `pre-commit autoupdate` does not silence this warning '
|
||||
'consider making an issue / pull request.'.format(
|
||||
self.repo_url, C.MANIFEST_FILE_LEGACY, C.MANIFEST_FILE,
|
||||
)
|
||||
),
|
||||
)
|
||||
return load_manifest(legacy_path)
|
||||
else:
|
||||
|
||||
@@ -50,7 +50,7 @@ def get_hook_message(
|
||||
raise ValueError('Expected one of (`end_msg`, `end_len`)')
|
||||
if end_msg is not None and (end_color is None or use_color is None):
|
||||
raise ValueError(
|
||||
'`end_color` and `use_color` are required with `end_msg`'
|
||||
'`end_color` and `use_color` are required with `end_msg`',
|
||||
)
|
||||
|
||||
if end_len:
|
||||
|
||||
@@ -20,7 +20,7 @@ class PrefixedCommandRunner(object):
|
||||
self,
|
||||
prefix_dir,
|
||||
popen=subprocess.Popen,
|
||||
makedirs=os.makedirs
|
||||
makedirs=os.makedirs,
|
||||
):
|
||||
self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
|
||||
self.__popen = popen
|
||||
|
||||
@@ -72,7 +72,7 @@ def _install_all(venvs, repo_url):
|
||||
|
||||
if need_installed:
|
||||
logger.info(
|
||||
'Installing environment for {}.'.format(repo_url)
|
||||
'Installing environment for {}.'.format(repo_url),
|
||||
)
|
||||
logger.info('Once installed this environment will be reused.')
|
||||
logger.info('This may take a few minutes...')
|
||||
@@ -102,7 +102,7 @@ def _validate_minimum_version(hook):
|
||||
'version {} is installed. '
|
||||
'Perhaps run `pip install --upgrade pre-commit`.'.format(
|
||||
hook['id'], hook_version, C.VERSION_PARSED,
|
||||
)
|
||||
),
|
||||
)
|
||||
exit(1)
|
||||
return hook
|
||||
@@ -147,7 +147,7 @@ class Repository(object):
|
||||
'Typo? Perhaps it is introduced in a newer version? '
|
||||
'Often `pre-commit autoupdate` fixes this.'.format(
|
||||
hook['id'], self.repo_config['repo'],
|
||||
)
|
||||
),
|
||||
)
|
||||
exit(1)
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ def _check_conditional(self, dct):
|
||||
cond_key=self.condition_key,
|
||||
op=op,
|
||||
cond_val=cond_val,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def staged_files_only(cmd_runner):
|
||||
except CalledProcessError:
|
||||
logger.warning(
|
||||
'Stashed changes conflicted with hook auto-fixes... '
|
||||
'Rolling back fixes...'
|
||||
'Rolling back fixes...',
|
||||
)
|
||||
# We failed to apply the patch, presumably due to fixes made
|
||||
# by hooks.
|
||||
|
||||
@@ -49,7 +49,7 @@ class Store(object):
|
||||
with io.open(os.path.join(self.directory, 'README'), 'w') as readme:
|
||||
readme.write(
|
||||
'This directory is maintained by the pre-commit project.\n'
|
||||
'Learn more: https://github.com/pre-commit/pre-commit\n'
|
||||
'Learn more: https://github.com/pre-commit/pre-commit\n',
|
||||
)
|
||||
|
||||
def _write_sqlite_db(self):
|
||||
@@ -68,7 +68,7 @@ class Store(object):
|
||||
' ref CHAR(255) NOT NULL,'
|
||||
' path CHAR(255) NOT NULL,'
|
||||
' PRIMARY KEY (repo, ref)'
|
||||
');'
|
||||
');',
|
||||
)
|
||||
|
||||
# Atomic file move
|
||||
|
||||
@@ -124,7 +124,7 @@ class CalledProcessError(RuntimeError):
|
||||
if maybe_text:
|
||||
output.append(
|
||||
b'\n ' +
|
||||
five.to_bytes(maybe_text).replace(b'\n', b'\n ')
|
||||
five.to_bytes(maybe_text).replace(b'\n', b'\n '),
|
||||
)
|
||||
else:
|
||||
output.append(b'(none)')
|
||||
@@ -134,8 +134,8 @@ class CalledProcessError(RuntimeError):
|
||||
'Command: {!r}\n'
|
||||
'Return code: {}\n'
|
||||
'Expected return code: {}\n'.format(
|
||||
self.cmd, self.returncode, self.expected_returncode
|
||||
)
|
||||
self.cmd, self.returncode, self.expected_returncode,
|
||||
),
|
||||
),
|
||||
b'Output: ', output[0], b'\n',
|
||||
b'Errors: ', output[1], b'\n',
|
||||
|
||||
Reference in New Issue
Block a user