Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): enable Ruff rules ISC, I001, B018 and fix the errors #2597

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions aws_lambda_powertools/utilities/batch/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
# For IntelliSense and Mypy to work, we need to account for possible SQS subclasses
# We need them as subclasses as we must access their message ID or sequence number metadata via dot notation
if has_pydantic:
from aws_lambda_powertools.utilities.parser.models import DynamoDBStreamRecordModel
from aws_lambda_powertools.utilities.parser.models import DynamoDBStreamRecordModel, SqsRecordModel
from aws_lambda_powertools.utilities.parser.models import (
KinesisDataStreamRecord as KinesisDataStreamRecordModel,
)
from aws_lambda_powertools.utilities.parser.models import SqsRecordModel

BatchTypeModels = Optional[
Union[Type[SqsRecordModel], Type[DynamoDBStreamRecordModel], Type[KinesisDataStreamRecordModel]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _put_record(self, data_record: DataRecord) -> None:

def _update_record(self, data_record: DataRecord):
logger.debug(f"Updating record for idempotency key: {data_record.idempotency_key}")
update_expression = "SET #response_data = :response_data, #expiry = :expiry, " "#status = :status"
update_expression = "SET #response_data = :response_data, #expiry = :expiry, #status = :status"
expression_attr_values: Dict[str, "AttributeValueTypeDef"] = {
":expiry": {"N": str(data_record.expiry_timestamp)},
":response_data": {"S": data_record.response_data},
Expand Down
3 changes: 1 addition & 2 deletions aws_lambda_powertools/utilities/parser/models/sns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Union
from typing import Type as TypingType
from typing import Union

from pydantic import BaseModel, root_validator
from pydantic.networks import HttpUrl
Expand Down
1 change: 0 additions & 1 deletion examples/parameters/tests/test_clear_cache_global.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from src import app

from aws_lambda_powertools.utilities import parameters
Expand Down
1 change: 0 additions & 1 deletion examples/parameters/tests/test_clear_cache_method.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from src import app


Expand Down
1 change: 0 additions & 1 deletion examples/parameters/tests/test_with_fixture.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from src import single_mock


Expand Down
3 changes: 0 additions & 3 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ ignore = [
"PLR2004", #https://beta.ruff.rs/docs/rules/magic-value-comparison/
"PLW0603", #https://beta.ruff.rs/docs/rules/global-statement/
"B904", # raise-without-from-inside-except - disabled temporarily
"B018", # useless-expression - disabled temporarily
"PLC1901", # Compare-to-empty-string - disabled temporarily
"ISC", # flake8-implicit-str-concat - disabled temporarily
"I001", # isort - disabled temporarily
]

# Exclude files and directories
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/idempotency/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def expected_params_update_item(serialized_lambda_response, hashed_idempotency_k
},
"Key": {"id": {"S": hashed_idempotency_key}},
"TableName": "TEST_TABLE",
"UpdateExpression": "SET #response_data = :response_data, " "#expiry = :expiry, #status = :status",
"UpdateExpression": "SET #response_data = :response_data, #expiry = :expiry, #status = :status",
}


Expand Down
2 changes: 1 addition & 1 deletion tests/functional/idempotency/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ def build_idempotency_update_item_stub(
},
"Key": {"id": {"S": idempotency_key_hash}},
"TableName": "TEST_TABLE",
"UpdateExpression": "SET #response_data = :response_data, " "#expiry = :expiry, #status = :status",
"UpdateExpression": "SET #response_data = :response_data, #expiry = :expiry, #status = :status",
}
2 changes: 1 addition & 1 deletion tests/unit/data_classes/test_code_pipeline_job_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_code_pipeline_event_non_json_user_parameters():
assert configuration.user_parameters is not None

with pytest.raises(json.decoder.JSONDecodeError):
configuration.decoded_user_parameters
assert configuration.decoded_user_parameters is not None


def test_code_pipeline_event_decoded_data():
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test_data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def data_property(self) -> list:
event_source = DataClassSample({})
event_str = (
"{'data_property': ['string', 0, 0.0, {'broken_data_property': "
+ "'[Cannot be deserialized]', 'raw_event': '[SENSITIVE]'}], 'raw_event': '[SENSITIVE]'}"
"'[Cannot be deserialized]', 'raw_event': '[SENSITIVE]'}], 'raw_event': '[SENSITIVE]'}"
)
assert str(event_source) == event_str

Expand Down Expand Up @@ -213,9 +213,8 @@ def data_property(self) -> DataClassTerminal:

event_source = DataClassRecursive({})
assert (
str(event_source)
== "{'data_property': {'raw_event': '[SENSITIVE]', 'terminal_property': 'end-recursion'},"
+ " 'raw_event': '[SENSITIVE]'}"
str(event_source) == "{'data_property': {'raw_event': '[SENSITIVE]', 'terminal_property': 'end-recursion'},"
" 'raw_event': '[SENSITIVE]'}"
)


Expand Down