From f2738bde19c8fb74ef4e7b38b1fdc4f2b6efd76a Mon Sep 17 00:00:00 2001 From: Changho Park Date: Fri, 22 Apr 2022 19:35:05 +0900 Subject: [PATCH 1/5] Print `-e` option and path for editable package --- pipenv/cli/command.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 0a3c6aeb90..9c84a73c4c 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -762,18 +762,24 @@ def requirements(state, dev=False, dev_only=False, hash=False): echo(crayons.normal(" ".join([prefix, package_index["url"]]))) if not dev_only: for req_name, value in lockfile["default"].items(): - if hash: - hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] + if value.get("editable", False): + echo(crayons.normal("-e " + value["path"])) else: - hashes = [] - echo(crayons.normal("".join([req_name, value["version"], *hashes]))) + if hash: + hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] + else: + hashes = [] + echo(crayons.normal("".join([req_name, value["version"], *hashes]))) if dev or dev_only: for req_name, value in lockfile["develop"].items(): - if hash: - hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] + if value.get("editable", False): + echo(crayons.normal("-e " + value["path"])) else: - hashes = [] - echo(crayons.normal("".join([req_name, value["version"], *hashes]))) + if hash: + hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] + else: + hashes = [] + echo(crayons.normal("".join([req_name, value["version"], *hashes]))) sys.exit(0) From 055199ff96e4a5a5374769840d3fda0bd32c2814 Mon Sep 17 00:00:00 2001 From: Changho Park Date: Fri, 22 Apr 2022 22:21:02 +0900 Subject: [PATCH 2/5] Reduce depth for logical complexity --- pipenv/cli/command.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 9c84a73c4c..cfdb1fc704 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -764,22 +764,20 @@ def requirements(state, dev=False, dev_only=False, hash=False): for req_name, value in lockfile["default"].items(): if value.get("editable", False): echo(crayons.normal("-e " + value["path"])) - else: - if hash: - hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] - else: - hashes = [] + elif hash: + hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] echo(crayons.normal("".join([req_name, value["version"], *hashes]))) + else: + echo(crayons.normal("".join([req_name, value["version"]]))) if dev or dev_only: for req_name, value in lockfile["develop"].items(): if value.get("editable", False): echo(crayons.normal("-e " + value["path"])) - else: - if hash: - hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] - else: - hashes = [] + elif hash: + hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] echo(crayons.normal("".join([req_name, value["version"], *hashes]))) + else: + echo(crayons.normal("".join([req_name, value["version"]]))) sys.exit(0) From 5ff0315ea6b782f8cee0ca716644e954f91d9dc6 Mon Sep 17 00:00:00 2001 From: Changho Park Date: Fri, 22 Apr 2022 22:22:06 +0900 Subject: [PATCH 3/5] Remove `crayons.normal` inside `echo` --- pipenv/cli/command.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index cfdb1fc704..e40ad3313c 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -759,25 +759,25 @@ def requirements(state, dev=False, dev_only=False, hash=False): lockfile = state.project.lockfile_content for i, package_index in enumerate(lockfile["_meta"]["sources"]): prefix = "-i" if i == 0 else "--extra-index-url" - echo(crayons.normal(" ".join([prefix, package_index["url"]]))) + echo(" ".join([prefix, package_index["url"]])) if not dev_only: for req_name, value in lockfile["default"].items(): if value.get("editable", False): - echo(crayons.normal("-e " + value["path"])) + echo("-e " + value["path"]) elif hash: hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] - echo(crayons.normal("".join([req_name, value["version"], *hashes]))) + echo("".join([req_name, value["version"], *hashes])) else: - echo(crayons.normal("".join([req_name, value["version"]]))) + echo("".join([req_name, value["version"]])) if dev or dev_only: for req_name, value in lockfile["develop"].items(): if value.get("editable", False): - echo(crayons.normal("-e " + value["path"])) + echo("-e " + value["path"]) elif hash: hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])] - echo(crayons.normal("".join([req_name, value["version"], *hashes]))) + echo("".join([req_name, value["version"], *hashes])) else: - echo(crayons.normal("".join([req_name, value["version"]]))) + echo("".join([req_name, value["version"]])) sys.exit(0) From 00c6a0cc6e8d1c51430b079a3f675caeb2cd1e5e Mon Sep 17 00:00:00 2001 From: Changho Park Date: Fri, 22 Apr 2022 22:57:35 +0900 Subject: [PATCH 4/5] Add news fragment --- news/5070.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5070.bugfix.rst diff --git a/news/5070.bugfix.rst b/news/5070.bugfix.rst new file mode 100644 index 0000000000..007806d86b --- /dev/null +++ b/news/5070.bugfix.rst @@ -0,0 +1 @@ +Fixes issue of ``requirements`` command problem by modifying to print ``-e`` and path of the editable package. \ No newline at end of file From b9c5061bfb2c446d13fc9ad34d1e01e83ae34565 Mon Sep 17 00:00:00 2001 From: Changho Park Date: Fri, 22 Apr 2022 23:07:37 +0900 Subject: [PATCH 5/5] Add newline new fragment --- news/5070.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/5070.bugfix.rst b/news/5070.bugfix.rst index 007806d86b..9fd8072d42 100644 --- a/news/5070.bugfix.rst +++ b/news/5070.bugfix.rst @@ -1 +1 @@ -Fixes issue of ``requirements`` command problem by modifying to print ``-e`` and path of the editable package. \ No newline at end of file +Fixes issue of ``requirements`` command problem by modifying to print ``-e`` and path of the editable package.