Skip to content

Commit

Permalink
Adding None-check to locate_via_py.
Browse files Browse the repository at this point in the history
Follow-up to wntrblm#53. Also

- Using single quotes instead of double quotes
- Adding Args/Returns section to docstring
  • Loading branch information
dhermes committed Sep 20, 2017
1 parent 95863f7 commit fb50f98
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ def locate_via_py(version):
version. We then make the python process print out its full
executable path which we use as the location for the version-
specific Python interpreter.
Args:
version (str): The desired Python version.
Returns:
Optional[str]: The full executable path for the Python ``version``,
if it is found.
"""
script = "import sys; print(sys.executable)"
script = 'import sys; print(sys.executable)'
py_exe = py.path.local.sysfind('py')
if py_exe:
if py_exe is not None:
try:
return py_exe.sysexec('-' + version, '-c', script).strip()
except py.process.cmdexec.Error:
Expand Down

0 comments on commit fb50f98

Please sign in to comment.