py27+ syntax improvements

This commit is contained in:
Anthony Sottile 2017-01-21 11:49:53 -08:00
parent 0a93f3bfdd
commit ba75867c93
9 changed files with 31 additions and 34 deletions

View file

@ -75,9 +75,9 @@ def no_git_env():
# while running pre-commit hooks in submodules.
# GIT_DIR: Causes git clone to clone wrong thing
# GIT_INDEX_FILE: Causes 'error invalid object ...' during commit
return dict(
(k, v) for k, v in os.environ.items() if not k.startswith('GIT_')
)
return {
k: v for k, v in os.environ.items() if not k.startswith('GIT_')
}
@contextlib.contextmanager
@ -164,10 +164,10 @@ def cmd_output(*cmd, **kwargs):
# py2/py3 on windows are more strict about the types here
cmd = tuple(five.n(arg) for arg in cmd)
kwargs['env'] = dict(
(five.n(key), five.n(value))
kwargs['env'] = {
five.n(key): five.n(value)
for key, value in kwargs.pop('env', {}).items()
) or None
} or None
try:
cmd = parse_shebang.normalize_cmd(cmd)