diff --git a/celery/backends/dynamodb.py b/celery/backends/dynamodb.py index cbce6cb9711..479e9ba2f02 100644 --- a/celery/backends/dynamodb.py +++ b/celery/backends/dynamodb.py @@ -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: @@ -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') @@ -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 @@ -336,9 +334,9 @@ 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 @@ -346,7 +344,7 @@ def _set_table_ttl(self): # 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.' diff --git a/t/integration/test_canvas.py b/t/integration/test_canvas.py index a5e68af5e3d..bf97cae4159 100644 --- a/t/integration/test_canvas.py +++ b/t/integration/test_canvas.py @@ -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): @@ -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: @@ -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() @@ -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) diff --git a/t/unit/backends/test_dynamodb.py b/t/unit/backends/test_dynamodb.py index 7a04c82d4e2..e211648db6f 100644 --- a/t/unit/backends/test_dynamodb.py +++ b/t/unit/backends/test_dynamodb.py @@ -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() @@ -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 ) @@ -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() @@ -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()