Fix pythonfinder bug unnesting python versions

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2018-07-17 03:25:18 -04:00
parent cc9c5a3ff8
commit 95f0df79e8
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ import abc
import operator
import six
from itertools import chain
from ..utils import KNOWN_EXTS
from ..utils import KNOWN_EXTS, unnest
@six.add_metaclass(abc.ABCMeta)
@@ -88,7 +88,7 @@ class BasePath(object):
if self.is_python and version_matcher(self.as_python):
return self
return
finder = ((child, child.as_python) for child in chain(*filter(None, self.pythons.values())) if child.as_python)
finder = ((child, child.as_python) for child in unnest(self.pythons.values()) if child.as_python)
py_filter = filter(
None, filter(lambda child: version_matcher(child[1]), finder)
)
+7
View File
@@ -8,6 +8,7 @@ import subprocess
import sys
from fnmatch import fnmatch
from .exceptions import InvalidPythonVersion
from itertools import chain
try:
from pathlib import Path
@@ -137,3 +138,9 @@ def fs_str(string):
_fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
def unnest(item):
if isinstance(next((i for i in item), None), (list, tuple)):
return chain(*filter(None, item))
return chain(filter(None, item))