Skip to content

Commit dbc4e70

Browse files
committed
Disable false positives in linting
1 parent 6ffc8c8 commit dbc4e70

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

jsonrpclib/SimpleJSONRPCServer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,32 @@
4545
SimpleXMLRPCDispatcher = xmlrpcserver.SimpleXMLRPCDispatcher
4646
SimpleXMLRPCRequestHandler = xmlrpcserver.SimpleXMLRPCRequestHandler
4747
CGIXMLRPCRequestHandler = xmlrpcserver.CGIXMLRPCRequestHandler
48-
resolve_dotted_attribute = xmlrpcserver.resolve_dotted_attribute
48+
resolve_dotted_attribute = xmlrpcserver.resolve_dotted_attribute # type: ignore # noqa: E501 # pylint: disable=invalid-name,line-too-long
4949
import socketserver
5050
except (ImportError, AttributeError):
5151
# Python 2 or IronPython
5252
# pylint: disable=F0401,E0611
53-
import SimpleXMLRPCServer as xmlrpcserver
54-
SimpleXMLRPCDispatcher = xmlrpcserver.SimpleXMLRPCDispatcher
55-
SimpleXMLRPCRequestHandler = xmlrpcserver.SimpleXMLRPCRequestHandler
56-
CGIXMLRPCRequestHandler = xmlrpcserver.CGIXMLRPCRequestHandler
57-
resolve_dotted_attribute = xmlrpcserver.resolve_dotted_attribute
58-
import SocketServer as socketserver
53+
import SimpleXMLRPCServer as xmlrpcserver # type: ignore
54+
SimpleXMLRPCDispatcher = xmlrpcserver.SimpleXMLRPCDispatcher # type: ignore # noqa: E501 # pylint: disable=invalid-name,line-too-long
55+
SimpleXMLRPCRequestHandler = xmlrpcserver.SimpleXMLRPCRequestHandler # type: ignore # noqa: E501 # pylint: disable=invalid-name,line-too-long
56+
CGIXMLRPCRequestHandler = xmlrpcserver.CGIXMLRPCRequestHandler # type: ignore # noqa: E501 # pylint: disable=invalid-name,line-too-long
57+
resolve_dotted_attribute = xmlrpcserver.resolve_dotted_attribute # type: ignore # noqa: E501 # pylint: disable=invalid-name,line-too-long
58+
import SocketServer as socketserver # type: ignore
5959

6060
try:
6161
# Windows
6262
import fcntl
6363
except ImportError:
6464
# Other systems
6565
# pylint: disable=C0103
66-
fcntl = None
66+
fcntl = None # type: ignore
6767

6868
try:
6969
# Python with support for Unix socket
7070
_AF_UNIX = socket.AF_UNIX
7171
except AttributeError:
7272
# Unix sockets are not supported, use a dummy value
73-
_AF_UNIX = -1
73+
_AF_UNIX = -1 # type: ignore
7474

7575
# Local modules
7676
from jsonrpclib import Fault

jsonrpclib/jsonrpc.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@
7777
except 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

8787
try:
8888
# Check GZip support
8989
import gzip
9090
except 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
9696
import jsonrpclib.config
@@ -115,11 +115,11 @@
115115
try:
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

188187
class 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

jsonrpclib/threadpool.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131

3232
try:
3333
# Python 3
34-
# pylint: disable=F0401
35-
import queue
34+
import queue # pylint: disable=F0401
3635
except ImportError:
3736
# Python 2
38-
# pylint: disable=F0401
39-
import Queue as queue
37+
import Queue as queue # type: ignore # pylint: disable=F0401
4038

4139
# ------------------------------------------------------------------------------
4240

jsonrpclib/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def to_bytes(string):
6262
Converts the given string into bytes
6363
"""
6464
# pylint: disable=E0602
65-
if type(string) is unicode:
65+
if type(string) is unicode: # noqa: F821
6666
return str(string)
6767
return string
6868

@@ -118,11 +118,11 @@ def is_enum(obj):
118118
return isinstance(obj, enum.Enum)
119119
except ImportError:
120120
# Pre-Python 3.4
121-
def is_enum(_):
121+
def is_enum(obj): # pylint: disable=unused-argument
122122
"""
123123
Before Python 3.4, enumerations didn't exist.
124124
125-
:param _: Object to test
125+
:param obj: Object to test
126126
:return: Always False
127127
"""
128128
return False

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[bdist_wheel]
22
universal = 1
3+
4+
[flake8]
5+
max-line-length = 80

0 commit comments

Comments
 (0)