Skip to content

Commit

Permalink
fix: Use sequencify for converting tuples to list
Browse files Browse the repository at this point in the history
  • Loading branch information
achillesrasquinha committed Feb 10, 2019
1 parent 9acdf9f commit 36326c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pipupgrade/_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pipupgrade.util.system import which, popen
from pipupgrade.util.string import kebab_case
from pipupgrade.util.environ import value_to_envval
from pipupgrade.util.types import sequencify

PIP9 = int(pip.__version__.split(".")[0]) < 10

Expand Down Expand Up @@ -46,7 +47,7 @@ def _get_pip_executable():
def call(*args, **kwargs):
pip_exec = kwargs.pop("pip_exec", _PIP_EXECUTABLE)

params = [pip_exec] + args
params = sequencify(pip_exec) + sequencify(args)

for flag, value in iteritems(kwargs):
if value != False:
Expand Down
5 changes: 5 additions & 0 deletions src/pipupgrade/util/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ def auto_typecast(value):
except (KeyError, ValueError, TypeError):
pass

return value

def sequencify(value, type_ = list):
if not isinstance(value, (list, tuple)):
value = type_([value])
return value

0 comments on commit 36326c4

Please sign in to comment.