From 63d2b6c5aa19c8df8332fc40c4748f6e3784db54 Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Thu, 7 Oct 2021 05:56:53 -0400 Subject: [PATCH 1/2] Tweak upload --verbose suggestion --- tests/test_utils.py | 7 +------ twine/utils.py | 11 +++++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index cbcba7d5..07965d54 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -285,12 +285,7 @@ def test_check_status_code_for_missing_status_code( if verbose: assert captured.out.count("Content received from server:\nForbidden\n") == 1 else: - assert ( - captured.out.count( - "For more details, retry the upload with the --verbose option.\n" - ) - == 1 - ) + assert captured.out.count("--verbose option") == 1 @pytest.mark.parametrize( diff --git a/twine/utils.py b/twine/utils.py index 0378f40e..6256ee0a 100644 --- a/twine/utils.py +++ b/twine/utils.py @@ -197,12 +197,15 @@ def check_status_code(response: requests.Response, verbose: bool) -> None: try: response.raise_for_status() except requests.HTTPError as err: + if not verbose: + logger.warning( + "Error during upload. " + "Retry with the --verbose option for more details." + ) + if response.text: logger.info("Content received from server:\n{}".format(response.text)) - if not verbose: - logger.warning( - "For more details, retry the upload with the --verbose option." - ) + raise err From f75b0a25e8f15bc8784ac2a79218c9ea67ef40c8 Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Thu, 7 Oct 2021 09:02:57 -0400 Subject: [PATCH 2/2] Create 817.bugfix.rst --- changelog/817.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/817.bugfix.rst diff --git a/changelog/817.bugfix.rst b/changelog/817.bugfix.rst new file mode 100644 index 00000000..5abcc059 --- /dev/null +++ b/changelog/817.bugfix.rst @@ -0,0 +1 @@ +Generalize ``--verbose`` suggestion when an upload fails.