Skip to content

Commit

Permalink
Remove unused variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Katz committed Dec 5, 2019
1 parent a2f80b6 commit 34ebad0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
16 changes: 7 additions & 9 deletions celery/backends/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from celery.exceptions import ImproperlyConfigured
from celery.five import string
from celery.utils.log import get_logger

from .base import KeyValueStoreBackend

try:
Expand Down Expand Up @@ -288,7 +287,6 @@ def _get_table_ttl_description(self):
description = self._client.describe_time_to_live(
TableName=self.table_name
)
status = description['TimeToLiveDescription']['TimeToLiveStatus']
except ClientError as e:
error_code = e.response['Error'].get('Code', 'Unknown')
error_message = e.response['Error'].get('Message', 'Unknown')
Expand Down Expand Up @@ -321,9 +319,9 @@ def _set_table_ttl(self):
'DynamoDB Time to Live is {situation} '
'on table {table}'
).format(
situation='already enabled' \
if status == 'ENABLED' \
else 'currently being enabled',
situation='already enabled'
if status == 'ENABLED'
else 'currently being enabled',
table=self.table_name
))
return description
Expand All @@ -336,17 +334,17 @@ def _set_table_ttl(self):
'DynamoDB Time to Live is {situation} '
'on table {table}'
).format(
situation='already disabled' \
if status == 'DISABLED' \
else 'currently being disabled',
situation='already disabled'
if status == 'DISABLED'
else 'currently being disabled',
table=self.table_name
))
return description

# The state shouldn't ever have any value beyond the four handled
# above, but to ease troubleshooting of potential future changes, emit
# a log showing the unknown state.
else: # pragma: no cover
else: # pragma: no cover
logger.warning((
'Unknown DynamoDB Time to Live status {status} '
'on table {table}. Attempting to continue.'
Expand Down
10 changes: 5 additions & 5 deletions t/integration/test_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_link_error_using_signature_eager(self):

exception = ExpectedException("Task expected to fail", "test")
assert (fail.apply().get(timeout=TIMEOUT, propagate=False), True) == (
exception, True)
exception, True)

@pytest.mark.flaky(reruns=5, reruns_delay=1, cause=is_retryable_exception)
def test_link_error_using_signature(self):
Expand All @@ -82,7 +82,7 @@ def test_link_error_using_signature(self):

exception = ExpectedException("Task expected to fail", "test")
assert (fail.delay().get(timeout=TIMEOUT, propagate=False), True) == (
exception, True)
exception, True)


class test_chain:
Expand All @@ -101,8 +101,8 @@ def test_single_chain(self, manager):
def test_complex_chain(self, manager):
c = (
add.s(2, 2) | (
add.s(4) | add_replaced.s(8) | add.s(16) | add.s(32)
) |
add.s(4) | add_replaced.s(8) | add.s(16) | add.s(32)
) |
group(add.s(i) for i in range(4))
)
res = c()
Expand Down Expand Up @@ -572,7 +572,7 @@ def test_redis_subscribed_channels_leak(self, manager):
# (existing from previous tests).
chord_header_task_count = 2
assert channels_before_count <= \
chord_header_task_count * total_chords + initial_channels_count
chord_header_task_count * total_chords + initial_channels_count

result_values = [
result.get(timeout=TIMEOUT)
Expand Down
10 changes: 4 additions & 6 deletions t/unit/backends/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_get_client_time_to_live_called(
app=self.app,
url='dynamodb://key:secret@test?ttl_seconds=30'
)
client = backend._get_client()
backend._get_client()

mock_validate_ttl_methods.assert_called_once()
mock_set_table_ttl.assert_called_once()
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_set_table_ttl_enable_when_disabled_succeeds(self):
}
}

res = self.backend._set_table_ttl()
self.backend._set_table_ttl()
mock_describe_time_to_live.assert_called_once_with(
TableName=self.backend.table_name
)
Expand All @@ -257,8 +257,7 @@ def test_set_table_ttl_enable_when_disabled_succeeds(self):
def test_set_table_ttl_enable_when_enabled_with_correct_attr_succeeds(self):
self.backend.time_to_live_seconds = 30
self.backend._client = MagicMock()
mock_update_time_to_live = self.backend._client.update_time_to_live = \
MagicMock()
self.backend._client.update_time_to_live = MagicMock()

mock_describe_time_to_live = \
self.backend._client.describe_time_to_live = MagicMock()
Expand Down Expand Up @@ -344,8 +343,7 @@ def test_set_table_ttl_enable_when_enabled_with_wrong_attr_raises(self):
def test_set_table_ttl_disable_when_disabled_succeeds(self):
self.backend.time_to_live_seconds = -1
self.backend._client = MagicMock()
mock_update_time_to_live = self.backend._client.update_time_to_live = \
MagicMock()
self.backend._client.update_time_to_live = MagicMock()
mock_describe_time_to_live = \
self.backend._client.describe_time_to_live = MagicMock()

Expand Down

0 comments on commit 34ebad0

Please sign in to comment.