From 86ab54e8a288de166d3babe71016c34ff9ff17e7 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 7 May 2021 21:58:04 +0200
Subject: [PATCH] fix(poetry): improve versioning resilience (#9911)

---
 lib/versioning/pep440/range.ts | 2 +-
 lib/versioning/poetry/index.ts | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/versioning/pep440/range.ts b/lib/versioning/pep440/range.ts
index 979e970ad0..280dd69ea1 100644
--- a/lib/versioning/pep440/range.ts
+++ b/lib/versioning/pep440/range.ts
@@ -59,7 +59,7 @@ export function getNewValue({
     logger.warn('Empty currentValue: ' + currentValue);
     return currentValue;
   }
-  if (rangeStrategy === 'replace') {
+  if (rangeStrategy === 'auto' || rangeStrategy === 'replace') {
     if (satisfies(newVersion, currentValue)) {
       return currentValue;
     }
diff --git a/lib/versioning/poetry/index.ts b/lib/versioning/poetry/index.ts
index 54499f89a1..2b75d1d8c3 100644
--- a/lib/versioning/poetry/index.ts
+++ b/lib/versioning/poetry/index.ts
@@ -80,18 +80,18 @@ const isGreaterThan = (a: string, b: string): boolean =>
   pep440.isGreaterThan(a, b);
 
 const isLessThanRange = (version: string, range: string): boolean =>
+  npm.isVersion(padZeroes(version)) &&
   npm.isLessThanRange(padZeroes(version), poetry2npm(range));
 
 export const isValid = (input: string): string | boolean =>
   npm.isValid(poetry2npm(input));
 
-const isStable = (version: string): boolean =>
-  version && npm.isStable(padZeroes(version));
+const isStable = (version: string): boolean => pep440.isStable(version);
 
-const isVersion = (input: string): string | boolean =>
-  npm.isVersion(padZeroes(input));
+const isVersion = (input: string): string | boolean => pep440.isVersion(input);
 
 const matches = (version: string, range: string): boolean =>
+  npm.isVersion(padZeroes(version)) &&
   npm.matches(padZeroes(version), poetry2npm(range));
 
 const getSatisfyingVersion = (versions: string[], range: string): string =>
-- 
GitLab