From 935c9b033e476ad564781bdb4ef7cd7fb5a46007 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Wed, 19 Feb 2020 19:24:48 +0100 Subject: [PATCH] make dateutil mandatory for api client Avoids differing incompatible return types depending on what modules are installed at runtime. This is backward incompatible though likely the less breaking variation as most environments should have dateutils installed due to the requirements.txt. Closes gh-1081 --- kubernetes/client/api_client.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/kubernetes/client/api_client.py b/kubernetes/client/api_client.py index fde1a17f48..fa52eaeae0 100644 --- a/kubernetes/client/api_client.py +++ b/kubernetes/client/api_client.py @@ -18,6 +18,7 @@ import os import re import tempfile +import dateutil.parser # python 2 and python 3 compatibility library import six @@ -582,10 +583,7 @@ def __deserialize_date(self, string): :return: date. """ try: - from dateutil.parser import parse - return parse(string).date() - except ImportError: - return string + return dateutil.parser.parse(string).date() except ValueError: raise rest.ApiException( status=0, @@ -601,10 +599,7 @@ def __deserialize_datatime(self, string): :return: datetime. """ try: - from dateutil.parser import parse - return parse(string) - except ImportError: - return string + return dateutil.parser.parse(string) except ValueError: raise rest.ApiException( status=0,