Skip to content

Commit 2477322

Browse files
pylint: fix keyword-arg-before-vararg cases
Fix all cases of W1113 keyword-arg-before-vararg. Part of #270
1 parent 2ab71b1 commit 2477322

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

tarantool/error.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
import os
88
import socket
9-
try:
10-
import ssl
11-
IS_SSL_SUPPORTED = True
12-
except ImportError:
13-
IS_SSL_SUPPORTED = False
149
import sys
1510
import warnings
1611

@@ -236,27 +231,35 @@ class NetworkError(DatabaseError):
236231
Error related to network.
237232
"""
238233

239-
def __init__(self, orig_exception=None, *args, **kwargs):
234+
def __init__(self, *args, **kwargs):
240235
"""
241-
:param orig_exception: Exception to wrap.
242-
:type orig_exception: optional
236+
:param args: Exception arguments. If the first argument is
237+
a socket exception, it is wrapped.
238+
:type args: :obj:`tuple`, optional
243239
244-
:param args: Wrapped exception arguments.
245-
:type args: :obj:`tuple`
240+
:param kwargs: Exception to wrap.
241+
:type args: :obj:`dict`, optional
246242
"""
247243

248244
self.errno = 0
249-
if hasattr(orig_exception, 'errno'):
250-
self.errno = orig_exception.errno
251-
if orig_exception:
245+
246+
if len(args) > 0:
247+
orig_exception = args[0]
248+
249+
if hasattr(orig_exception, 'errno'):
250+
self.errno = orig_exception.errno
251+
252252
if isinstance(orig_exception, socket.timeout):
253253
self.message = "Socket timeout"
254254
super().__init__(0, self.message)
255-
elif isinstance(orig_exception, socket.error):
255+
return
256+
257+
if isinstance(orig_exception, socket.error):
256258
self.message = os.strerror(orig_exception.errno)
257259
super().__init__(orig_exception.errno, self.message)
258-
else:
259-
super().__init__(orig_exception, *args, **kwargs)
260+
return
261+
262+
super().__init__(*args, **kwargs)
260263

261264

262265
class NetworkWarning(UserWarning):
@@ -269,23 +272,25 @@ class SslError(DatabaseError):
269272
Error related to SSL.
270273
"""
271274

272-
def __init__(self, orig_exception=None, *args):
275+
def __init__(self, *args, **kwargs):
273276
"""
274-
:param orig_exception: Exception to wrap.
275-
:type orig_exception: optional
277+
:param args: Exception arguments. If the first argument is
278+
a socket exception, it is wrapped.
279+
:type args: :obj:`tuple`, optional
276280
277-
:param args: Wrapped exception arguments.
278-
:type args: :obj:`tuple`
281+
:param kwargs: Exception to wrap.
282+
:type args: :obj:`dict`, optional
279283
"""
280284

281285
self.errno = 0
282-
if hasattr(orig_exception, 'errno'):
283-
self.errno = orig_exception.errno
284-
if orig_exception:
285-
if IS_SSL_SUPPORTED and isinstance(orig_exception, ssl.SSLError):
286-
super().__init__(orig_exception, *args)
287-
else:
288-
super().__init__(orig_exception, *args)
286+
287+
if len(args) > 0:
288+
orig_exception = args[0]
289+
290+
if hasattr(orig_exception, 'errno'):
291+
self.errno = orig_exception.errno
292+
293+
super().__init__(*args, **kwargs)
289294

290295

291296
class ClusterDiscoveryWarning(UserWarning):

0 commit comments

Comments
 (0)