fix pylint error for 3rd-party with python3.x 86/297186/3
authorbiao716.wang <biao716.wang@samsung.com>
Fri, 11 Aug 2023 09:53:15 +0000 (18:53 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Fri, 11 Aug 2023 10:47:16 +0000 (19:47 +0900)
Change-Id: I3f4e1ab34cbdcda4615fed0dd5ecd1351a9822b4
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
17 files changed:
mic/3rdparty/requests/compat.py
mic/3rdparty/requests/models.py
mic/3rdparty/requests/packages/chardet/chardistribution.py
mic/3rdparty/requests/packages/chardet/langcyrillicmodel.py
mic/3rdparty/requests/packages/urllib3/connection.py
mic/3rdparty/requests/packages/urllib3/connectionpool.py
mic/3rdparty/requests/packages/urllib3/contrib/ntlmpool.py
mic/3rdparty/requests/packages/urllib3/contrib/pyopenssl.py
mic/3rdparty/requests/packages/urllib3/packages/ordered_dict.py
mic/3rdparty/requests/packages/urllib3/request.py
mic/3rdparty/requests/packages/urllib3/response.py
mic/3rdparty/requests/packages/urllib3/util/retry.py
mic/3rdparty/requests/packages/urllib3/util/ssl_.py
mic/3rdparty/urlgrabber/byterange.py
mic/3rdparty/urlgrabber/grabber.py
mic/3rdparty/urlgrabber/mirror.py
mic/3rdparty/urlgrabber/progress.py

index aba7f0d..0c04505 100755 (executable)
@@ -35,7 +35,7 @@ except (ImportError, SyntaxError):
 if is_py2:
     from urllib.parse import quote, unquote, quote_plus, unquote_plus, urlencode
     from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
-    from urllib2 import parse_http_list
+    from urllib2 import parse_http_list # pylint: disable=import-error
     import http.cookiejar
     from http.cookies import Morsel
     from io import StringIO
index 2332426..42369c5 100755 (executable)
@@ -623,10 +623,6 @@ class Response(object):
         """Returns true if :attr:`status_code` is 'OK'."""
         return self.ok
 
-    def __bool__(self):
-        """Returns true if :attr:`status_code` is 'OK'."""
-        return self.ok
-
     def __iter__(self):
         """Allows you to use a response as an iterator."""
         return self.iter_content(128)
index 4e64a00..8e8f7c8 100755 (executable)
@@ -76,7 +76,7 @@ class CharDistributionAnalysis:
             self._mTotalChars += 1
             # order is valid
             if order < self._mTableSize:
-                if 512 > self._mCharToFreqOrder[order]:
+                if 512 > self._mCharToFreqOrder[order]: # pylint: disable=unsubscriptable-object
                     self._mFreqChars += 1
 
     def get_confidence(self):
index a86f54b..b28030b 100755 (executable)
@@ -308,7 +308,7 @@ MacCyrillicModel = {
   'mTypicalPositiveRatio': 0.976601,
   'keepEnglishLetter': False,
   'charsetName': "MacCyrillic"
-};
+}
 
 Ibm866Model = {
   'charToOrderMap': IBM866_CharToOrderMap,
index 01f5630..c6c6e84 100755 (executable)
@@ -156,7 +156,7 @@ class HTTPConnection(_HTTPConnection, object):
         self._prepare_conn(conn)
 
 
-class HTTPSConnection(HTTPConnection):
+class HTTPSConnection(HTTPConnection): # pylint: disable=function-redefined
     default_port = port_by_scheme['https']
 
     def __init__(self, host, port=None, key_file=None, cert_file=None,
index d88312a..c5f8b8e 100755 (executable)
@@ -76,11 +76,11 @@ class ConnectionPool(object):
         return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
-        self.close()
+        self.close() # pylint: disable=too-many-function-args
         # Return False to re-raise any potential exceptions
         return False
 
-    def close():
+    def close(self):
         """
         Close all pooled connections and disable the pool.
         """
index f802195..ab0d831 100755 (executable)
@@ -9,7 +9,7 @@ try:
 except ImportError:
     from http.client import HTTPSConnection
 from logging import getLogger
-from ntlm import ntlm
+from ntlm import ntlm # pylint: disable=import-error
 
 from urllib3 import HTTPSConnectionPool
 
index b2c34a8..4d1c27e 100755 (executable)
@@ -45,15 +45,15 @@ Module Variables
 '''
 
 try:
-    from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT
-    from ndg.httpsclient.subj_alt_name import SubjectAltName as BaseSubjectAltName
+    from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT # pylint: disable=import-error
+    from ndg.httpsclient.subj_alt_name import SubjectAltName as BaseSubjectAltName # pylint: disable=import-error
 except SyntaxError as e:
     raise ImportError(e)
 
 import OpenSSL.SSL
 from pyasn1.codec.der import decoder as der_decoder
 from pyasn1.type import univ, constraint
-from socket import _fileobject, timeout
+from socket import _fileobject, timeout # pylint: disable=no-name-in-module
 import ssl
 import select
 
index 1b42e8f..67517b5 100755 (executable)
@@ -139,7 +139,7 @@ class OrderedDict(dict):
         for k in self:
             yield (k, self[k])
 
-    def update(*args, **kwds):
+    def update(self, *args, **kwds):
         '''od.update(E, **F) -> None.  Update od from dict/iterable E and F.
 
         If E is a dict instance, does:           for k in E: od[k] = E[k]
index ab48b3c..fd2d482 100755 (executable)
@@ -46,7 +46,7 @@ class RequestMethods(object):
     def urlopen(self, method, url, body=None, headers=None,
                 encode_multipart=True, multipart_boundary=None,
                 **kw):  # Abstract
-        raise NotImplemented("Classes extending RequestMethods must implement "
+        raise NotImplementedError("Classes extending RequestMethods must implement "
                              "their own ``urlopen`` method.")
 
     def request(self, method, url, fields=None, headers=None, **urlopen_kw):
index b29bacb..1220c36 100755 (executable)
@@ -259,7 +259,8 @@ class HTTPResponse(io.IOBase):
 
             except BaseSSLError as e:
                 # FIXME: Is there a better way to differentiate between SSLErrors?
-                if 'read operation timed out' not in str(e):  # Defensive:
+                if 'read operation timed out' not in str(e): # pylint: disable=not-callable
+                    # Defensive:
                     # This shouldn't happen but just in case we're missing an edge
                     # case, let's avoid swallowing SSL errors.
                     raise
index 7ee9f25..e823ff2 100755 (executable)
@@ -219,7 +219,7 @@ class Retry(object):
         """
         if self.total is False and error:
             # Disabled, indicate to re-raise the error.
-            raise six.reraise(type(error), error, _stacktrace)
+            raise six.reraise(type(error), error, _stacktrace) # pylint: disable=raising-bad-type
 
         total = self.total
         if total is not None:
@@ -234,7 +234,7 @@ class Retry(object):
         if error and self._is_connection_error(error):
             # Connect retry?
             if connect is False:
-                raise six.reraise(type(error), error, _stacktrace)
+                raise six.reraise(type(error), error, _stacktrace) # pylint: disable=raising-bad-type
             elif connect is not None:
                 connect -= 1
             _observed_errors += 1
@@ -242,7 +242,7 @@ class Retry(object):
         elif error and self._is_read_error(error):
             # Read retry?
             if read is False:
-                raise six.reraise(type(error), error, _stacktrace)
+                raise six.reraise(type(error), error, _stacktrace) # pylint: disable=raising-bad-type
             elif read is not None:
                 read -= 1
             _observed_errors += 1
index b846d42..40141d4 100755 (executable)
@@ -49,7 +49,8 @@ try:
 except ImportError:
     import sys
 
-    class SSLContext(object):  # Platform-specific: Python 2 & 3.1
+    class SSLContext(object): # pylint: disable=function-redefined
+        # Platform-specific: Python 2 & 3.1
         supports_set_ciphers = ((2, 7) <= sys.version_info < (3,) or
                                 (3, 2) <= sys.version_info)
 
index e341add..86e4a02 100755 (executable)
@@ -47,7 +47,7 @@ if sys.version_info >= (3,):
     # and returns str instead of unicode somewhere.
     from io import StringIO
 else:
-    from cStringIO import StringIO
+    from cStringIO import StringIO # pylint: disable=import-error
 
 class RangeError(IOError):
     """Error raised when an unsatisfiable range is requested."""
@@ -244,7 +244,7 @@ class FileRangeHandler(FileHandler):
         mtype = mimetypes.guess_type(file)[0]
         if host:
             host, port = urllib.splitport(host)
-            if port or socket.gethostbyname(host) not in self.get_names():
+            if port or socket.gethostbyname(host) not in self.get_names(): # pylint: disable=unsupported-membership-test
                 raise URLError('file not on local host')
         fo = open(localfile,'rb')
         brange = req.headers.get('Range',None)
@@ -298,7 +298,7 @@ class FTPRangeHandler(FTPHandler):
         path, attrs = splitattr(req.get_selector())
         dirs = path.split('/')
         dirs = map(unquote, dirs)
-        dirs, file = dirs[:-1], dirs[-1]
+        dirs, file = dirs[:-1], dirs[-1] # pylint: disable=unsubscriptable-object
         if dirs and not dirs[0]:
             dirs = dirs[1:]
         try:
@@ -344,7 +344,7 @@ class FTPRangeHandler(FTPHandler):
             if retrlen is not None and retrlen >= 0:
                 headers += "Content-Length: %d\n" % retrlen
             sf = StringIO(headers)
-            headers = mimetools.Message(sf)
+            headers = mimetools.Message(sf) # pylint: disable=undefined-variable
             return addinfourl(fp, headers, req.get_full_url())
         except ftplib.all_errors as msg:
             raise IOError('ftp error', msg).with_traceback(sys.exc_info()[2])
index cfc33bb..d627249 100755 (executable)
@@ -569,7 +569,7 @@ if sys.version_info >= (3,):
     # and returns str instead of unicode somewhere.
     from io import StringIO
 else:
-    from cStringIO import StringIO
+    from cStringIO import StringIO # pylint: disable=import-error
 
 from .byterange import range_tuple_normalize, range_tuple_to_header, RangeError
 
@@ -992,9 +992,9 @@ class URLGrabberOptions:
 
         if self.libproxy:
             global _libproxy_cache
-            if _libproxy_cache is None:
+            if _libproxy_cache is None: # pylint: disable=used-before-assignment
                 try:
-                    import libproxy
+                    import libproxy # pylint: disable=import-error
                     _libproxy_cache = libproxy.ProxyFactory()
                 except:
                     _libproxy_cache = False
@@ -1450,7 +1450,7 @@ class PyCurlFileObject(object):
         hdrfp = StringIO()
         hdrfp.write(self._hdr_dump[statusend:])
         hdrfp.seek(0)
-        self._parsed_hdr =  email.message_from_string(hdrfp)
+        self._parsed_hdr =  email.message_from_string(hdrfp) # pylint: disable=undefined-variable
         return self._parsed_hdr
 
     hdr = property(_return_hdr_obj)
@@ -1740,7 +1740,7 @@ class PyCurlFileObject(object):
         # mstenner did before here
         return (self.fo, self.hdr)
 
-        try:
+        try: # pylint: disable=unreachable
             if self.opts.timeout:
                 old_to = socket.getdefaulttimeout()
                 socket.setdefaulttimeout(self.opts.timeout)
@@ -1909,14 +1909,14 @@ class PyCurlFileObject(object):
                 err.url = self.url
                 raise err
 
-            except socket.timeout as e:
+            except socket.timeout as e: # pylint: disable=bad-except-order
                 raise URLGrabError(12, _('Timeout on %s: %s') % (self.url, e))
-                err.url = self.url
+                err.url = self.url # pylint: disable=unreachable
                 raise err
 
             except IOError as e:
                 raise URLGrabError(4, _('IOError on %s: %s') %(self.url, e))
-                err.url = self.url
+                err.url = self.url # pylint: disable=unreachable
                 raise err
 
             newsize = len(new)
@@ -1974,7 +1974,7 @@ class PyCurlFileObject(object):
         if not self._complete: self._do_grab()
         return self.fo.readline()
 
-        i = self._rbuf.find('\n')
+        i = self._rbuf.find('\n') # pylint: disable=unreachable
         while i < 0 and not (0 < limit <= len(self._rbuf)):
             L = len(self._rbuf)
             self._fill_buffer(L + self._rbufsize)
@@ -2110,8 +2110,8 @@ def _loads(s):
             if s[j] in ')]':
                 if s[j] == ')':
                     l = tuple(l)
-                stk[0].append(l)
-                l, stk = stk
+                stk[0].append(l) # pylint: disable=unsubscriptable-object
+                l, stk = stk # pylint: disable=unpacking-non-sequence
             i = j = j + 1
         elif s[j] in '[(':
             stk = l, stk
index 3a62fab..093b51b 100755 (executable)
@@ -98,7 +98,7 @@ if sys.version_info >= (3,):
     # We use a version check because python2 also has _thread
     import _thread as thread
 else:
-    import thread
+    import thread # pylint: disable=import-error
 
 try:
     import urllib.parse as urlparse
@@ -346,7 +346,7 @@ class MirrorGroup:
         self.increment_mirror(gr, action)
         if action and action.get('fail', 0):
             sys.exc_info()[1].errors = gr.errors
-            raise
+            raise # pylint: disable=misplaced-bare-raise
 
     def increment_mirror(self, gr, action={}):
         """Tell the mirror object increment the mirror index
index 7c35bed..0d28dd3 100755 (executable)
@@ -30,7 +30,7 @@ if sys.version_info >= (3,):
     # We use a version check because python2 also has _thread
     import _thread as thread
 else:
-    import thread
+    import thread # pylint: disable=import-error
 
 # Code from http://mail.python.org/pipermail/python-list/2000-May/033365.html
 def terminal_width(fd=1):