mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 13:00:10 -06:00
drop python.exe extension on windows on shebang
This commit is contained in:
committed by
Anthony Sottile
parent
8e9f927e3d
commit
273326b89b
@@ -55,7 +55,7 @@ def is_our_script(filename: str) -> bool:
|
||||
|
||||
def shebang() -> str:
|
||||
if sys.platform == 'win32':
|
||||
py = SYS_EXE
|
||||
py, _ = os.path.splitext(SYS_EXE)
|
||||
else:
|
||||
exe_choices = [
|
||||
f'python{sys.version_info[0]}.{sys.version_info[1]}',
|
||||
|
||||
@@ -56,8 +56,13 @@ def patch_sys_exe(exe):
|
||||
|
||||
|
||||
def test_shebang_windows():
|
||||
with patch_platform('win32'), patch_sys_exe('python'):
|
||||
assert shebang() == '#!/usr/bin/env python'
|
||||
|
||||
|
||||
def test_shebang_windows_drop_ext():
|
||||
with patch_platform('win32'), patch_sys_exe('python.exe'):
|
||||
assert shebang() == '#!/usr/bin/env python.exe'
|
||||
assert shebang() == '#!/usr/bin/env python'
|
||||
|
||||
|
||||
def test_shebang_posix_not_on_path():
|
||||
|
||||
Reference in New Issue
Block a user