Skip to content

Commit 5622760

Browse files
committed
Address more @asottile's review comments
1 parent 38da98d commit 5622760

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pre_commit/languages/python.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def _norm(path):
6868
def _get_default_version(): # pragma: no cover (platform dependent)
6969
# First attempt from `sys.executable` (or the realpath)
7070
exe = _find_by_sys_executable()
71+
if exe:
72+
return exe
7173

7274
# Next try the `pythonX.X` executable
7375
exe = 'python{}.{}'.format(*sys.version_info)

tests/languages/python_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import mock
88
import pytest
99

10-
import pre_commit.parse_shebang
10+
from pre_commit import parse_shebang
1111
from pre_commit.languages import python
1212

1313

@@ -50,7 +50,7 @@ def mocked_find_executable(exe):
5050
with mock.patch.object(sys, 'executable', exe):
5151
with mock.patch.object(os.path, 'realpath', return_value=realpath):
5252
with mock.patch.object(
53-
pre_commit.parse_shebang, 'find_executable',
53+
parse_shebang, 'find_executable',
5454
side_effect=mocked_find_executable,
5555
):
5656
assert python._find_by_sys_executable() == expected

0 commit comments

Comments
 (0)