You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2021/11/03 22:38:39 UTC

[libcloud] 03/04: Fix lint violations.

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch understand-ai-intelligent-retry
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit bfda9fc09527b8b8adb2c0d33462da9eee8ef537
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Wed Nov 3 22:20:05 2021 +0100

    Fix lint violations.
---
 libcloud/utils/misc.py  | 16 ++++++++--------
 libcloud/utils/retry.py | 26 +++++++++++++++++---------
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/libcloud/utils/misc.py b/libcloud/utils/misc.py
index 747d55c..3932015 100644
--- a/libcloud/utils/misc.py
+++ b/libcloud/utils/misc.py
@@ -22,9 +22,12 @@ from libcloud.common.providers import get_driver as _get_driver
 from libcloud.common.providers import set_driver as _set_driver
 # Imported for backward compatibility
 # noinspection PyProtectedMember
-from libcloud.utils.retry import (Retry,
-                                  DEFAULT_DELAY, DEFAULT_TIMEOUT, DEFAULT_BACKOFF,
-                                  TRANSIENT_SSL_ERROR, TransientSSLError)
+from libcloud.utils.retry import Retry  # flake8: noqa
+from libcloud.utils.retry import DEFAULT_DELAY  # noqa: F401
+from libcloud.utils.retry import DEFAULT_TIMEOUT  # noqa: F401
+from libcloud.utils.retry import DEFAULT_BACKOFF  # noqa: F401
+from libcloud.utils.retry import TRANSIENT_SSL_ERROR  # noqa: F401
+from libcloud.utils.retry import TransientSSLError  # noqa: F401
 
 
 __all__ = [
@@ -51,8 +54,8 @@ def find(l, predicate):
 # been moved to "libcloud.common.providers" module
 get_driver = _get_driver
 set_driver = _set_driver
-# Note: This is an alias for backward-compatibility for a function which has been
-# moved to "libcloud.util.retry" module
+# Note: This is an alias for backward-compatibility for a function which has
+# been moved to "libcloud.util.retry" module
 retry = Retry
 
 
@@ -254,6 +257,3 @@ class ReprMixin(object):
 
     def __str__(self):
         return str(self.__repr__())
-
-
-
diff --git a/libcloud/utils/retry.py b/libcloud/utils/retry.py
index baa6c73..af77572 100644
--- a/libcloud/utils/retry.py
+++ b/libcloud/utils/retry.py
@@ -53,7 +53,9 @@ class MinimalRetry:
     def __init__(self, retry_delay=DEFAULT_DELAY,
                  timeout=DEFAULT_TIMEOUT, backoff=DEFAULT_BACKOFF):
         """
-        Wrapper around retrying that helps to handle common transient exceptions.
+        Wrapper around retrying that helps to handle common transient
+        exceptions.
+
         This minimalistic version only retries SSL errors and rate limiting.
 
         :param retry_delay: retry delay between the attempts.
@@ -102,7 +104,8 @@ class MinimalRetry:
                     last_exc = exc
 
                     if isinstance(exc, RateLimitReachedError):
-                        _logger.debug("You are being rate limited, backing off...")
+                        _logger.debug("You are being rate limited, backing "
+                                      "off...")
 
                         # NOTE: Retry after defaults to 0 in the
                         # RateLimitReachedError class so we a use more
@@ -130,11 +133,15 @@ class MinimalRetry:
 class Retry(MinimalRetry):
 
     def __init__(self, retry_exceptions=RETRY_EXCEPTIONS,
-                 retry_delay=DEFAULT_DELAY, timeout=DEFAULT_TIMEOUT, backoff=DEFAULT_BACKOFF):
+                 retry_delay=DEFAULT_DELAY, timeout=DEFAULT_TIMEOUT,
+                 backoff=DEFAULT_BACKOFF):
         """
-        Wrapper around retrying that helps to handle common transient exceptions.
-        This version retries the errors that `libcloud.utils.retry:MinimalRetry` retries
-        and all errors of the exception types that are given.
+        Wrapper around retrying that helps to handle common transient
+        exceptions.
+
+        This version retries the errors that
+        `libcloud.utils.retry:MinimalRetry` retries and all errors of the
+        exception types that are given.
 
         :param retry_exceptions: types of exceptions to retry on.
         :param retry_delay: retry delay between the attempts.
@@ -143,15 +150,16 @@ class Retry(MinimalRetry):
 
         :Example:
 
-        retry_request = Retry(retry_exceptions=(httplib.NotConnected,), timeout=1, retry_delay=1, backoff=1)
+        retry_request = Retry(retry_exceptions=(httplib.NotConnected,),
+                              timeout=1, retry_delay=1, backoff=1)
         retry_request(self.connection.request)()
         """
 
-        super().__init__(retry_delay=retry_delay, timeout=timeout, backoff=backoff)
+        super().__init__(retry_delay=retry_delay, timeout=timeout,
+                         backoff=backoff)
         if retry_exceptions is None:
             retry_exceptions = RETRY_EXCEPTIONS
         self.retry_exceptions = retry_exceptions
 
     def should_retry(self, exception):
         return type(exception) in self.retry_exceptions
-