From fb50f98c9890fe02b1a09938237411eef7d25b97 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Wed, 20 Sep 2017 15:45:19 -0700 Subject: [PATCH] Adding None-check to `locate_via_py`. Follow-up to #53. Also - Using single quotes instead of double quotes - Adding Args/Returns section to docstring --- nox/virtualenv.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nox/virtualenv.py b/nox/virtualenv.py index 0296da08..9bb8d2c1 100644 --- a/nox/virtualenv.py +++ b/nox/virtualenv.py @@ -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: