run dead, remove dead code

via https://github.com/asottile/dead
This commit is contained in:
Anthony Sottile 2021-12-22 11:30:55 -08:00
parent de177e8850
commit 42b0a263a6
3 changed files with 2 additions and 69 deletions

View file

@ -1,4 +1,3 @@
import itertools
import logging
import os.path
import shlex
@ -31,10 +30,6 @@ PRIOR_HASHES = (
CURRENT_HASH = b'138fd403232d2ddd5efb44317e38bf03'
TEMPLATE_START = '# start templated\n'
TEMPLATE_END = '# end templated\n'
# Homebrew/homebrew-core#35825: be more timid about appropriate `PATH`
# #1312 os.defpath is too restrictive on BSD
POSIX_SEARCH_PATH = ('/usr/local/bin', '/usr/bin', '/bin')
SYS_EXE = os.path.basename(os.path.realpath(sys.executable))
def _hook_paths(
@ -54,26 +49,6 @@ def is_our_script(filename: str) -> bool:
return any(h in contents for h in (CURRENT_HASH,) + PRIOR_HASHES)
def shebang() -> str:
if sys.platform == 'win32':
py, _ = os.path.splitext(SYS_EXE)
else:
exe_choices = [
f'python{sys.version_info[0]}.{sys.version_info[1]}',
f'python{sys.version_info[0]}',
]
# avoid searching for bare `python` as it's likely to be python 2
if SYS_EXE != 'python':
exe_choices.append(SYS_EXE)
for path, exe in itertools.product(POSIX_SEARCH_PATH, exe_choices):
if os.access(os.path.join(path, exe), os.X_OK):
py = exe
break
else:
py = SYS_EXE
return f'#!/usr/bin/env {py}'
def _install_hook_script(
config_file: str,
hook_type: str,