From 7279fb0a008376a1befb55e74ee2f7fd515e4f5b Mon Sep 17 00:00:00 2001 From: Prajjwal Nijhara Date: Sat, 2 May 2020 19:41:46 +0530 Subject: [PATCH] Fix some code quality and bug-risk issues --- .deepsource.toml | 19 +++++++++++++++++++ autobahn/asyncio/component.py | 2 +- autobahn/asyncio/websocket.py | 2 +- autobahn/twisted/component.py | 2 +- autobahn/wamp/auth.py | 2 +- autobahn/wamp/component.py | 4 +++- autobahn/wamp/cryptosign.py | 2 +- 7 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 000000000..b15b681b6 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,19 @@ +version = 1 + +test_patterns = [ + "*/test/**", + "*/test/**/*.py" +] + +exclude_patterns = [ + "twisted/plugins/**", + "examples/**" +] + +[[analyzers]] +name = "python" +enabled = true + + [analyzers.meta] + runtime_version = "3.x.x" + \ No newline at end of file diff --git a/autobahn/asyncio/component.py b/autobahn/asyncio/component.py index 886dc4b43..3691a3d29 100644 --- a/autobahn/asyncio/component.py +++ b/autobahn/asyncio/component.py @@ -55,7 +55,7 @@ def _unique_list(seq): def _camel_case_from_snake_case(snake): parts = snake.split('_') - return parts[0] + ''.join([s.capitalize() for s in parts[1:]]) + return parts[0] + ''.join(s.capitalize() for s in parts[1:]) def _create_transport_factory(loop, transport, session_factory): diff --git a/autobahn/asyncio/websocket.py b/autobahn/asyncio/websocket.py index 1a6416cd4..829b73fe0 100644 --- a/autobahn/asyncio/websocket.py +++ b/autobahn/asyncio/websocket.py @@ -93,7 +93,7 @@ def _consume(self): self.waiter = Future(loop=self.factory.loop or txaio.config.loop) def process(_): - while len(self.receive_queue): + while self.receive_queue: data = self.receive_queue.popleft() if self.transport: self._dataReceived(data) diff --git a/autobahn/twisted/component.py b/autobahn/twisted/component.py index 6c1294ff6..a4d71a731 100644 --- a/autobahn/twisted/component.py +++ b/autobahn/twisted/component.py @@ -67,7 +67,7 @@ def _unique_list(seq): def _camel_case_from_snake_case(snake): parts = snake.split('_') - return parts[0] + ''.join([s.capitalize() for s in parts[1:]]) + return parts[0] + ''.join(s.capitalize() for s in parts[1:]) def _create_transport_factory(reactor, transport, session_factory): diff --git a/autobahn/wamp/auth.py b/autobahn/wamp/auth.py index 0120b0d99..6f1b19894 100644 --- a/autobahn/wamp/auth.py +++ b/autobahn/wamp/auth.py @@ -579,7 +579,7 @@ def generate_wcs(length=14): :rtype: bytes """ assert(type(length) == int) - return "".join([random.choice(WCS_SECRET_CHARSET) for _ in range(length)]).encode('ascii') + return "".join(random.choice(WCS_SECRET_CHARSET) for _ in range(length)).encode('ascii') @public diff --git a/autobahn/wamp/component.py b/autobahn/wamp/component.py index 8aec3132f..d33801f57 100644 --- a/autobahn/wamp/component.py +++ b/autobahn/wamp/component.py @@ -268,9 +268,11 @@ def __init__(self, idx, kind, url, endpoint, serializers, retry_delay_growth=1.5, retry_delay_jitter=0.1, proxy=None, - options=dict()): + options=None): """ """ + if options is None: + options = dict() self.idx = idx self.type = kind diff --git a/autobahn/wamp/cryptosign.py b/autobahn/wamp/cryptosign.py index 0449c61e5..ebc39b6ff 100644 --- a/autobahn/wamp/cryptosign.py +++ b/autobahn/wamp/cryptosign.py @@ -183,7 +183,7 @@ def _read_ssh_ed25519_privkey(keydata): ssh_end = keydata.find(SSH_END) keydata = keydata[len(SSH_BEGIN):ssh_end] - keydata = ''.join([x.strip() for x in keydata.split()]) + keydata = ''.join(x.strip() for x in keydata.split()) blob = binascii.a2b_base64(keydata) blob = blob[len(OPENSSH_KEY_V1):]