Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def uninstall(ctx, state, all_dev=False, all=False, **kwargs):
"""Uninstalls a provided package and removes it from Pipfile."""
from ..core import do_uninstall

retcode = do_uninstall(
if retcode := do_uninstall(
state.project,
packages=state.installstate.packages,
editable_packages=state.installstate.editables,
Expand All @@ -293,8 +293,7 @@ def uninstall(ctx, state, all_dev=False, all=False, **kwargs):
pypi_mirror=state.pypi_mirror,
categories=state.installstate.categories,
ctx=ctx,
)
if retcode:
):
sys.exit(retcode)


Expand Down Expand Up @@ -667,7 +666,7 @@ def sync(ctx, state, bare=False, user=False, unused=False, **kwargs):
"""Installs all packages specified in Pipfile.lock."""
from ..core import do_sync

retcode = do_sync(
if retcode := do_sync(
state.project,
dev=state.installstate.dev,
python=state.python,
Expand All @@ -680,8 +679,7 @@ def sync(ctx, state, bare=False, user=False, unused=False, **kwargs):
system=state.system,
extra_pip_args=state.installstate.extra_pip_args,
categories=state.installstate.categories,
)
if retcode:
):
ctx.abort()


Expand Down Expand Up @@ -720,13 +718,15 @@ def scripts(state):
scripts = state.project.parsed_pipfile.get("scripts", {})
first_column_width = max(len(word) for word in ["Command"] + list(scripts))
second_column_width = max(len(word) for word in ["Script"] + list(scripts.values()))
lines = ["{0:<{width}} Script".format("Command", width=first_column_width)]
lines.append("{} {}".format("-" * first_column_width, "-" * second_column_width))
lines = [
"{0:<{width}} Script".format("Command", width=first_column_width),
f'{"-" * first_column_width} {"-" * second_column_width}',
]
lines.extend(
"{0:<{width}} {1}".format(name, script, width=first_column_width)
for name, script in scripts.items()
)
echo("\n".join(line for line in lines))
echo("\n".join(lines))


@cli.command(
Expand Down Expand Up @@ -786,7 +786,7 @@ def requirements(
if categories_list:
for category in categories_list:
category = get_lockfile_section_using_pipfile_category(category.strip())
deps.update(lockfile.get(category, {}))
deps |= lockfile.get(category, {})
else:
if dev or dev_only:
deps.update(lockfile["develop"])
Expand Down
15 changes: 8 additions & 7 deletions pipenv/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,22 @@ def validate_python_path(ctx, param, value):
# autodetection but it may also be a value which will be searched in
# the path or an absolute path. To report errors as early as possible
# we'll report absolute paths which do not exist:
if isinstance(value, (str, bytes)):
if os.path.isabs(value) and not os.path.isfile(value):
raise BadParameter("Expected Python at path %s does not exist" % value)
if (
isinstance(value, (str, bytes))
and os.path.isabs(value)
and not os.path.isfile(value)
):
raise BadParameter(f"Expected Python at path {value} does not exist")
return value


def validate_bool_or_none(ctx, param, value):
if value is not None:
return click_types.BOOL(value)
return False
return click_types.BOOL(value) if value is not None else False


def validate_pypi_mirror(ctx, param, value):
if value and not is_valid_url(value):
raise BadParameter("Invalid PyPI mirror URL: %s" % value)
raise BadParameter(f"Invalid PyPI mirror URL: {value}")
return value


Expand Down
Loading