Skip to content

Commit d332a14

Browse files
committed
Format fix
1 parent 94965bf commit d332a14

File tree

6 files changed

+39
-27
lines changed

6 files changed

+39
-27
lines changed

docs/conf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@
6464
# List of patterns, relative to source directory, that match files and
6565
# directories to ignore when looking for source files.
6666
# This pattern also affects html_static_path and html_extra_path.
67-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".gitignore", "requirements.txt"]
67+
exclude_patterns = [
68+
"_build",
69+
"Thumbs.db",
70+
".DS_Store",
71+
".gitignore",
72+
"requirements.txt",
73+
]
6874

6975
# The name of the Pygments (syntax highlighting) style to use.
7076
pygments_style = None

jsonrpclib/jsonclass.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ def load(obj, classes=None):
307307
)
308308
else:
309309
raise TranslationError(
310-
"Constructor args must be a dict or a list, "
311-
"not {0}".format(type(params).__name__)
310+
"Constructor args must be a dict or a list, not {0}".format(
311+
type(params).__name__
312+
)
312313
)
313314

314315
# Remove the class information, as it must be ignored during the

jsonrpclib/jsonrpc.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ def close(self):
236236

237237

238238
class TransportMixIn(object):
239-
""" Just extends the XML-RPC transport where necessary. """
239+
"""
240+
Just extends the XML-RPC transport where necessary.
241+
"""
240242

241243
# for Python 2.7 support
242244
_connection = None
@@ -305,7 +307,7 @@ def emit_additional_headers(self, connection):
305307
# Not available this version of Python (should not happen)
306308
pass
307309
else:
308-
for (key, value) in extra_headers:
310+
for key, value in extra_headers:
309311
additional_headers[key] = value
310312

311313
# Prepare the merged dictionary
@@ -1235,9 +1237,7 @@ def dump(
12351237
If a method, and params are not in a listish or a Fault,
12361238
error out.
12371239
"""
1238-
raise TypeError(
1239-
"Params must be a dict, list, tuple " "or Fault instance."
1240-
)
1240+
raise TypeError("Params must be a dict, list, tuple or Fault instance.")
12411241

12421242
# Prepares the JSON-RPC content
12431243
payload = Payload(rpcid=rpcid, version=version)
@@ -1250,8 +1250,7 @@ def dump(
12501250
if not isinstance(methodname, utils.STRING_TYPES) and not is_response:
12511251
# Neither a request nor a response
12521252
raise ValueError(
1253-
"Method name must be a string, or is_response "
1254-
"must be set to True."
1253+
"Method name must be a string, or is_response must be set to True."
12551254
)
12561255

12571256
if config.use_jsonclass:

tests/test_compatibility.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def tearDown(self):
5959

6060
# Version 2.0 Tests
6161
def test_positional(self):
62-
""" Positional arguments in a single call """
62+
"""Positional arguments in a single call"""
6363
result = self.client.subtract(23, 42)
6464
self.assertTrue(result == -19)
6565
result = self.client.subtract(42, 23)
@@ -77,7 +77,7 @@ def test_positional(self):
7777
self.assertTrue(response == verify_response)
7878

7979
def test_named(self):
80-
""" Named arguments in a single call """
80+
"""Named arguments in a single call"""
8181
result = self.client.subtract(subtrahend=23, minuend=42)
8282
self.assertTrue(result == 19)
8383
result = self.client.subtract(minuend=42, subtrahend=23)
@@ -95,7 +95,7 @@ def test_named(self):
9595
self.assertTrue(response == verify_response)
9696

9797
def test_notification(self):
98-
""" Testing a notification (response should be null) """
98+
"""Testing a notification (response should be null)"""
9999
result = self.client._notify.update(1, 2, 3, 4, 5)
100100
self.assertTrue(result is None)
101101
request = json.loads(self.history.request)
@@ -110,7 +110,7 @@ def test_notification(self):
110110
self.assertTrue(response == verify_response)
111111

112112
def test_non_existent_method(self):
113-
""" Testing behaviour when calling a non-existent method """
113+
"""Testing behaviour when calling a non-existent method"""
114114
self.assertRaises(jsonrpclib.ProtocolError, self.client.foobar)
115115
request = json.loads(self.history.request)
116116
response = json.loads(self.history.response)
@@ -128,14 +128,14 @@ def test_non_existent_method(self):
128128
self.assertTrue(response == verify_response)
129129

130130
def test_special_method(self):
131-
""" Tests behaviour on dunder methods """
131+
"""Tests behaviour on dunder methods"""
132132
self.assertRaises(
133133
AttributeError, getattr, self.client, "__special_method__"
134134
)
135135
self.assertIsNone(self.history.request)
136136

137137
def test_invalid_json(self):
138-
""" Tests behaviour on invalid JSON request """
138+
"""Tests behaviour on invalid JSON request"""
139139
invalid_json = (
140140
'{"jsonrpc": "2.0", "method": "foobar, ' + '"params": "bar", "baz]'
141141
)
@@ -149,7 +149,7 @@ def test_invalid_json(self):
149149
self.assertTrue(response == verify_response)
150150

151151
def test_invalid_request(self):
152-
""" Tests incomplete request """
152+
"""Tests incomplete request"""
153153
invalid_request = '{"jsonrpc": "2.0", "method": 1, "params": "bar"}'
154154
self.client._run_request(invalid_request)
155155
response = json.loads(self.history.response)
@@ -161,7 +161,7 @@ def test_invalid_request(self):
161161
self.assertTrue(response == verify_response)
162162

163163
def test_batch_invalid_json(self):
164-
""" Tests invalid JSON request on batch call """
164+
"""Tests invalid JSON request on batch call"""
165165
invalid_request = (
166166
'[ {"jsonrpc": "2.0", "method": "sum", '
167167
+ '"params": [1,2,4], "id": "1"},{"jsonrpc": "2.0", "method" ]'
@@ -176,7 +176,7 @@ def test_batch_invalid_json(self):
176176
self.assertTrue(response == verify_response)
177177

178178
def test_empty_array(self):
179-
""" Tests empty array as request """
179+
"""Tests empty array as request"""
180180
invalid_request = "[]"
181181
self.client._run_request(invalid_request)
182182
response = json.loads(self.history.response)
@@ -188,7 +188,7 @@ def test_empty_array(self):
188188
self.assertTrue(response == verify_response)
189189

190190
def test_nonempty_array(self):
191-
""" Tests array as request """
191+
"""Tests array as request"""
192192
invalid_request = "[1,2]"
193193
request_obj = json.loads(invalid_request)
194194
self.client._run_request(invalid_request)
@@ -203,7 +203,7 @@ def test_nonempty_array(self):
203203
self.assertTrue(resp == verify_resp)
204204

205205
def test_batch(self):
206-
""" Tests batch call """
206+
"""Tests batch call"""
207207
multicall = jsonrpclib.MultiCall(self.client)
208208
multicall.sum(1, 2, 4)
209209
multicall._notify.notify_hello(7)
@@ -272,7 +272,7 @@ def test_batch(self):
272272
self.assertTrue(response == verify_response)
273273

274274
def test_batch_notifications(self):
275-
""" Tests batch notifications """
275+
"""Tests batch notifications"""
276276
multicall = jsonrpclib.MultiCall(self.client)
277277
multicall._notify.notify_sum(1, 2, 4)
278278
multicall._notify.notify_hello(7)
@@ -290,7 +290,8 @@ def test_batch_notifications(self):
290290
self.assertTrue(self.history.response == "")
291291

292292
def test_url_query_string(self):
293-
""" Tests if the query string arguments are kept """
293+
"""Tests if the query string arguments are kept"""
294+
294295
# Prepare a simple server
295296
class ReqHandler(BaseHTTPRequestHandler):
296297
"""

tests/test_server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323

2424
def add(a, b):
25-
""" Basic addition """
25+
"""Basic addition"""
2626
return a + b
2727

2828

2929
def sleep(t):
3030
start = time.time()
3131
while time.time() - start < t:
32-
time.sleep(.1)
32+
time.sleep(0.1)
3333

3434

3535
class PooledServerTests(unittest.TestCase):
@@ -71,8 +71,12 @@ def test_default_pool(self, pool=None, max_time=3):
7171
self.assertEqual(result, rand1 + rand2)
7272

7373
# Check pauses (using different clients)
74-
threads = [threading.Thread(target=ServerProxy(
75-
target_url).sleep, args=(1,)) for _ in range(5)]
74+
threads = [
75+
threading.Thread(
76+
target=ServerProxy(target_url).sleep, args=(1,)
77+
)
78+
for _ in range(5)
79+
]
7680
start_time = time.time()
7781
for thread in threads:
7882
thread.start()

tests/test_threadpool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ def testException(self):
385385
"""
386386
Tests if an exception is correctly hidden
387387
"""
388+
388389
# Define the exception
389390
def thrower(ex):
390391
raise ex

0 commit comments

Comments
 (0)