pre-commit-hooks: python3.6+
diff --git a/pre_commit_hooks/util.py b/pre_commit_hooks/util.py
index 3b960e3..e04b015 100644
--- a/pre_commit_hooks/util.py
+++ b/pre_commit_hooks/util.py
@@ -1,9 +1,6 @@
-from __future__ import absolute_import
-from __future__ import print_function
-from __future__ import unicode_literals
-
import subprocess
from typing import Any
+from typing import Optional
from typing import Set
@@ -11,18 +8,17 @@
pass
-def added_files(): # type: () -> Set[str]
+def added_files() -> Set[str]:
cmd = ('git', 'diff', '--staged', '--name-only', '--diff-filter=A')
return set(cmd_output(*cmd).splitlines())
-def cmd_output(*cmd, **kwargs): # type: (*str, **Any) -> str
- retcode = kwargs.pop('retcode', 0)
+def cmd_output(*cmd: str, retcode: Optional[int] = 0, **kwargs: Any) -> str:
kwargs.setdefault('stdout', subprocess.PIPE)
kwargs.setdefault('stderr', subprocess.PIPE)
proc = subprocess.Popen(cmd, **kwargs)
stdout, stderr = proc.communicate()
- stdout = stdout.decode('UTF-8')
+ stdout = stdout.decode()
if retcode is not None and proc.returncode != retcode:
raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
return stdout