7777except ImportError :
7878 # Python 2
7979 # pylint: disable=F0401,E0611
80- from httplib import HTTPConnection
81- from urlparse import urlparse
82- from xmlrpclib import Transport as XMLTransport
83- from xmlrpclib import SafeTransport as XMLSafeTransport
84- from xmlrpclib import ServerProxy as XMLServerProxy
85- from xmlrpclib import _Method as XML_Method
80+ from httplib import HTTPConnection # type: ignore
81+ from urlparse import urlparse # type: ignore
82+ from xmlrpclib import Transport as XMLTransport # type: ignore
83+ from xmlrpclib import SafeTransport as XMLSafeTransport # type: ignore
84+ from xmlrpclib import ServerProxy as XMLServerProxy # type: ignore
85+ from xmlrpclib import _Method as XML_Method # type: ignore
8686
8787try :
8888 # Check GZip support
8989 import gzip
9090except ImportError :
9191 # Python can be built without zlib/gzip support
9292 # pylint: disable=C0103
93- gzip = None
93+ gzip = None # type: ignore
9494
9595# Library includes
9696import jsonrpclib .config
115115try :
116116 # pylint: disable=F0401,E0611
117117 # Using cjson
118- import cjson
118+ import cjson # type: ignore
119119 _logger .debug ("Using cjson as JSON library" )
120120
121121 # Declare cjson methods
122- def jdumps (obj , encoding = 'utf-8' ):
122+ def jdumps (obj , encoding = 'utf-8' ): # pylint: disable=unused-argument
123123 """
124124 Serializes ``obj`` to a JSON formatted string, using cjson.
125125 """
@@ -139,7 +139,7 @@ def jloads(json_string):
139139 _logger .debug ("Using json as JSON library" )
140140 except ImportError :
141141 try :
142- import simplejson as json
142+ import simplejson as json # type: ignore
143143 _logger .debug ("Using simplejson as JSON library" )
144144 except ImportError :
145145 _logger .error ("No supported JSON library found" )
@@ -156,7 +156,7 @@ def jdumps(obj, encoding='utf-8'):
156156 return json .dumps (obj , encoding = encoding )
157157 else :
158158 # Python 3
159- def jdumps (obj , encoding = 'utf-8' ):
159+ def jdumps (obj , encoding = 'utf-8' ): # pylint: disable=unused-argument
160160 """
161161 Serializes ``obj`` to a JSON formatted string.
162162 """
@@ -182,7 +182,6 @@ class ProtocolError(Exception):
182182 * an error message (string)
183183 * a (code, message) tuple
184184 """
185- pass
186185
187186
188187class AppError (ProtocolError ):
@@ -199,11 +198,21 @@ def data(self):
199198
200199 :return: The data associated to the error, or None
201200 """
202- return self .args [0 ][2 ]
201+ # Don't know why the pylint error shows up
202+ return self .args [0 ][2 ] # pylint: disable=unsubscriptable-object
203203
204204
205- class TransportError ( ProtocolError ):
205+ class TransportError (ProtocolError ):
206+ """
207+ Transport error: a specialized protocol error
208+ """
206209 def __init__ (self , url , errcode , errmsg , msg ):
210+ """
211+ :param url: Target URL
212+ :param errcode: HTTP error code
213+ :param errmsg: HTTP error code description
214+ :param msg: Exception message
215+ """
207216 ProtocolError .__init__ (self , url , errcode , errmsg , msg )
208217
209218 self .url = url
@@ -212,9 +221,8 @@ def __init__(self, url, errcode, errmsg, msg):
212221 self .msg = msg
213222
214223 def __repr__ (self ):
215- return (
216- "<%s for %s: %s %s>" %
217- (self .__class__ .__name__ , self .url , self .errcode , self .errmsg )
224+ return "<{} for {}: {} {}>" .format (
225+ type (self ).__name__ , self .url , self .errcode , self .errmsg
218226 )
219227
220228
@@ -273,7 +281,7 @@ def close(self):
273281 try :
274282 # Convert the whole final string
275283 data = utils .from_bytes (data )
276- except :
284+ except ( TypeError , ValueError ) :
277285 # Try a pass-through
278286 pass
279287
0 commit comments