From 34cfed4aac708a9bcb4de04e3fccf619bdadb6c2 Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Mon, 1 Nov 2021 16:42:26 -0500 Subject: [PATCH] Support --skip-existing with GCP Artifact Registry GCP includes the same "already exist" note as PyPI in a 400 response, but in `text` rather than `reason`. Fixes #816. --- changelog/816.feature.rst | 1 + twine/commands/upload.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog/816.feature.rst diff --git a/changelog/816.feature.rst b/changelog/816.feature.rst new file mode 100644 index 00000000..adbf6cb9 --- /dev/null +++ b/changelog/816.feature.rst @@ -0,0 +1 @@ +Allow the ``--skip-existing`` option to work with GCP Artifact Registry. diff --git a/twine/commands/upload.py b/twine/commands/upload.py index 99d19f70..45b6f2a1 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -58,8 +58,8 @@ def skip_upload( return ( # pypiserver (https://pypi.org/project/pypiserver) status == 409 - # PyPI / TestPyPI - or (status == 400 and "already exist" in reason) + # PyPI / TestPyPI / GCP Artifact Registry + or (status == 400 and any("already exist" in x for x in [reason, text])) # Nexus Repository OSS (https://www.sonatype.com/nexus-repository-oss) or (status == 400 and any("updating asset" in x for x in [reason, text])) # Artifactory (https://jfrog.com/artifactory/)