Skip to content

Commit

Permalink
Merge pull request #4450 from pypa/bugfix/4446
Browse files Browse the repository at this point in the history
Fix #4446 function calls in ``setup.py`` can't be parsed rightly.
  • Loading branch information
frostming authored Sep 1, 2020
2 parents 4dec947 + fdd83e1 commit 5fafc81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/4446.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that function calls in ``setup.py`` can't be parsed rightly.
11 changes: 10 additions & 1 deletion pipenv/vendor/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,15 @@ def parse_setup_function(self):
return setup


def _ensure_hashable(item):
try:
hash(item)
except TypeError:
return str(item)
else:
return item


def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # noqa:C901
# type: (Any, bool, Optional[Analyzer], bool) -> Union[List[Any], Dict[Any, Any], Tuple[Any, ...], STRING_TYPE]
unparse = partial(
Expand All @@ -1003,7 +1012,7 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no
constant = ast.Ellipsis
unparsed = item
if isinstance(item, ast.Dict):
unparsed = dict(zip(unparse(item.keys), unparse(item.values)))
unparsed = dict(zip(map(_ensure_hashable, unparse(item.keys)), unparse(item.values)))
elif isinstance(item, ast.List):
unparsed = [unparse(el) for el in item.elts]
elif isinstance(item, ast.Tuple):
Expand Down

0 comments on commit 5fafc81

Please sign in to comment.