Skip to content

Commit

Permalink
chore: refactor code quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
akshgpt7 committed Mar 19, 2021
1 parent 4979c3a commit 73aa78a
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 12 deletions.
16 changes: 16 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version = 1

test_patterns = ["t/**"]

exclude_patterns = [
"requirements/",
"extra/**",
"examples/**"
]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
3 changes: 2 additions & 1 deletion kombu/asynchronous/http/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ def ioctl(cmd):
else:
setopt(_pycurl.INFILESIZE, len(body))
elif request.method == 'GET':
assert not request.body
if request.body:
raise AssertionError

if request.auth_username is not None:
auth_mode = {
Expand Down
8 changes: 3 additions & 5 deletions kombu/transport/qpid.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,7 @@ def _has_queue(self, queue, **kwargs):
:rtype: bool
"""
if self._broker.getQueue(queue):
return True
else:
return False
return bool(self._broker.getQueue(queue))

def queue_declare(self, queue, passive=False, durable=False,
exclusive=False, auto_delete=True, nowait=False,
Expand Down Expand Up @@ -884,7 +881,8 @@ def basic_ack(self, delivery_tag, multiple=False):
:type multiple: bool
"""
assert multiple is False
if multiple is not False:
raise AssertionError
self.qos.ack(delivery_tag)

def basic_reject(self, delivery_tag, requeue=False):
Expand Down
3 changes: 2 additions & 1 deletion kombu/transport/virtual/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ def restore_unacked_once(self, stderr=None):
if not self.restore_at_shutdown or not self.channel.do_restore:
return
if getattr(state, 'restored', None):
assert not state
if state:
raise AssertionError
return
try:
if state:
Expand Down
2 changes: 1 addition & 1 deletion kombu/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def nested(*managers): # pragma: no cover
while exits:
exit = exits.pop()
try:
if exit(*exc):
if sys.exit(*exc):
exc = (None, None, None)
except:
exc = sys.exc_info()
Expand Down
3 changes: 2 additions & 1 deletion kombu/utils/eventio.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def poll(self, timeout, round=math.ceil,
events |= WRITE
if event & POLLERR or event & POLLNVAL or event & POLLHUP:
events |= ERR
assert events
if not events:
raise AssertionError
if not isinstance(fd, Integral):
fd = fd.fileno()
ready.append((fd, events))
Expand Down
1 change: 0 additions & 1 deletion t/unit/asynchronous/test_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_supports_Timer_interface(self):
assert x.schedule is x

def test_handle_error(self):
from datetime import datetime
on_error = Mock(name='on_error')

s = Timer(on_error=on_error)
Expand Down
2 changes: 1 addition & 1 deletion t/unit/test_clocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_order(self):
assert a <= b
assert b >= a

assert (timetuple(134, time(), 'A', 'obj').__lt__(tuple()) is
assert (timetuple(134, time(), 'A', 'obj').__lt__(()) is
NotImplemented)
assert timetuple(134, t2, 'A', 'obj') > timetuple(133, t1, 'A', 'obj')
assert timetuple(134, t1, 'B', 'obj') > timetuple(134, t1, 'A', 'obj')
Expand Down
1 change: 0 additions & 1 deletion t/unit/transport/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,6 @@ def test_get_client(self):
assert conn.transport.channel_errors

def test_check_at_least_we_try_to_connect_and_fail(self):
import redis
connection = Connection('redis://localhost:65534/')

with pytest.raises(redis.exceptions.ConnectionError):
Expand Down

0 comments on commit 73aa78a

Please sign in to comment.