Skip to content

Commit 2cc79f8

Browse files
authored
chore: Upgrade ruff to 0.0.244 (#2884)
1 parent 6064249 commit 2cc79f8

File tree

20 files changed

+49
-66
lines changed

20 files changed

+49
-66
lines changed

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pytest-xdist~=2.5
44
pytest-env~=0.6.2
55
pytest-rerunfailures~=9.1.1
66
pyyaml~=5.4
7-
ruff==0.0.239 # loose the requirement once it is more stable
7+
ruff==0.0.244 # loose the requirement once it is more stable
88

99
# Test requirements
1010
pytest~=6.2.5

ruff.toml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,5 @@ target-version = "py37"
2626
# python scripts in bin/ needs some python path configurations before import
2727
"bin/*.py" = ["E402"] # E402: module-import-not-at-top-of-file
2828

29-
# Quick exclusion of too-many-args in legacy files,
30-
# due to there are too many violations in them.
31-
"samtranslator/metrics/metrics.py" = ["PLR0913"]
32-
"samtranslator/model/api/api_generator.py" = ["PLR0913"]
33-
"samtranslator/model/api/http_api_generator.py" = ["PLR0913"]
34-
"samtranslator/model/apigateway.py" = ["PLR0913"]
35-
"samtranslator/model/apigatewayv2.py" = ["PLR0913"]
36-
"samtranslator/model/eventsources/push.py" = ["PLR0913"]
37-
"samtranslator/model/eventsources/scheduler.py" = ["PLR0913"]
38-
"samtranslator/model/role_utils/role_constructor.py" = ["PLR0913"]
39-
"samtranslator/model/sam_resources.py" = ["PLR0913"]
40-
"samtranslator/model/stepfunctions/events.py" = ["PLR0913"]
41-
"samtranslator/model/stepfunctions/generators.py" = ["PLR0913"]
42-
"samtranslator/open_api/open_api.py" = ["PLR0913"]
43-
"samtranslator/plugins/api/implicit_api_plugin.py" = ["PLR0913"]
44-
"samtranslator/plugins/api/implicit_http_api_plugin.py" = ["PLR0913"]
45-
"samtranslator/plugins/api/implicit_rest_api_plugin.py" = ["PLR0913"]
46-
"samtranslator/plugins/application/serverless_app_plugin.py" = ["PLR0913"]
47-
"samtranslator/swagger/swagger.py" = ["PLR0913"]
48-
"samtranslator/translator/translator.py" = ["PLR0913"]
49-
"samtranslator/validator/value_validator.py" = ["PLR0913"]
29+
[pylint]
30+
max-args = 6 # We have many functions reaching 6 args

samtranslator/model/api/api_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _set_condition(self, condition, template_conditions): # type: ignore[no-unt
160160

161161

162162
class ApiGenerator:
163-
def __init__(
163+
def __init__( # noqa: too-many-arguments
164164
self,
165165
logical_id: str,
166166
cache_cluster_enabled: Optional[Intrinsicable[bool]],
@@ -425,7 +425,7 @@ def _construct_stage(
425425

426426
return stage
427427

428-
def _construct_api_domain(
428+
def _construct_api_domain( # noqa: too-many-branches
429429
self, rest_api: ApiGatewayRestApi, route53_record_set_groups: Any
430430
) -> Tuple[Optional[ApiGatewayDomainName], Optional[List[ApiGatewayBasePathMapping]], Any]:
431431
"""
@@ -752,7 +752,7 @@ def _add_auth(self) -> None:
752752

753753
self.definition_body = self._openapi_postprocess(swagger_editor.swagger)
754754

755-
def _construct_usage_plan(self, rest_api_stage: Optional[ApiGatewayStage] = None) -> Any:
755+
def _construct_usage_plan(self, rest_api_stage: Optional[ApiGatewayStage] = None) -> Any: # noqa: too-many-branches
756756
"""Constructs and returns the ApiGateway UsagePlan, ApiGateway UsagePlanKey, ApiGateway ApiKey for Auth.
757757
758758
:param model.apigateway.ApiGatewayStage stage: the stage of rest api
@@ -1015,7 +1015,7 @@ def _add_models(self) -> None:
10151015

10161016
self.definition_body = self._openapi_postprocess(swagger_editor.swagger)
10171017

1018-
def _openapi_postprocess(self, definition_body: Dict[str, Any]) -> Dict[str, Any]:
1018+
def _openapi_postprocess(self, definition_body: Dict[str, Any]) -> Dict[str, Any]: # noqa: too-many-branches
10191019
"""
10201020
Convert definitions to openapi 3 in definition body if OpenApiVersion flag is specified.
10211021

samtranslator/model/api/http_api_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434

3535
class HttpApiGenerator:
36-
def __init__(
36+
def __init__( # noqa: too-many-arguments
3737
self,
3838
logical_id: str,
3939
stage_variables: Optional[Dict[str, Intrinsicable[str]]],
@@ -237,7 +237,7 @@ def _update_default_path(self) -> None:
237237
if DefaultStageName in paths:
238238
paths[f"/{DefaultStageName}"] = paths.pop(DefaultStageName)
239239

240-
def _construct_api_domain(
240+
def _construct_api_domain( # noqa: too-many-branches
241241
self, http_api: ApiGatewayV2HttpApi, route53_record_set_groups: Dict[str, Route53RecordSetGroup]
242242
) -> Tuple[
243243
Optional[ApiGatewayV2DomainName],

samtranslator/model/apigateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class ApiGatewayApiKey(Resource):
262262
class ApiGatewayAuthorizer:
263263
_VALID_FUNCTION_PAYLOAD_TYPES = [None, "TOKEN", "REQUEST"]
264264

265-
def __init__( # type: ignore[no-untyped-def]
265+
def __init__( # type: ignore[no-untyped-def]# noqa: too-many-arguments
266266
self,
267267
api_logical_id=None,
268268
name=None,

samtranslator/model/apigatewayv2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ApiGatewayV2ApiMapping(Resource):
7575

7676

7777
class ApiGatewayV2Authorizer:
78-
def __init__( # type: ignore[no-untyped-def]
78+
def __init__( # type: ignore[no-untyped-def] # noqa: too-many-arguments
7979
self,
8080
api_logical_id=None,
8181
name=None,

samtranslator/model/eventsources/pull.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_event_source_arn(self) -> Optional[PassThrough]:
8989
"""Return the value to assign to lambda event source mapping's EventSourceArn."""
9090

9191
@cw_timer(prefix=FUNCTION_EVETSOURCE_METRIC_PREFIX)
92-
def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def]
92+
def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: too-many-branches
9393
"""Returns the Lambda EventSourceMapping to which this pull event corresponds. Adds the appropriate managed
9494
policy to the function's execution role, if such a role is provided.
9595

samtranslator/model/eventsources/push.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class PushEventSource(ResourceMacro, metaclass=ABCMeta):
5959
principal: str = None # type: ignore
6060
relative_id: str # overriding the Optional[str]: for event, relative id is not None
6161

62-
def _construct_permission( # type: ignore[no-untyped-def]
62+
def _construct_permission( # type: ignore[no-untyped-def] # noqa: too-many-arguments
6363
self, function, source_arn=None, source_account=None, suffix="", event_source_token=None, prefix=None
6464
):
6565
"""Constructs the Lambda Permission resource allowing the source service to invoke the function this event
@@ -563,7 +563,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def]
563563
resources.append(subscription)
564564
return resources
565565

566-
def _inject_subscription(
566+
def _inject_subscription( # noqa: too-many-arguments
567567
self,
568568
protocol: str,
569569
endpoint: str,
@@ -750,7 +750,9 @@ def _get_permission(self, resources_to_link, stage, suffix): # type: ignore[no-
750750

751751
return self._construct_permission(resources_to_link["function"], source_arn=source_arn, suffix=suffix) # type: ignore[no-untyped-call]
752752

753-
def _add_swagger_integration(self, api, api_id, function, intrinsics_resolver): # type: ignore[no-untyped-def]
753+
def _add_swagger_integration( # type: ignore[no-untyped-def] # noqa: too-many-statements
754+
self, api, api_id, function, intrinsics_resolver
755+
):
754756
"""Adds the path and method for this Api event source to the Swagger body for the provided RestApi.
755757
756758
:param model.apigateway.ApiGatewayRestApi rest_api: the RestApi to which the path and method should be added.
@@ -938,7 +940,7 @@ def get_rest_api_id_string(rest_api_id: Any) -> Any:
938940
return rest_api_id["Ref"] if isinstance(rest_api_id, dict) and "Ref" in rest_api_id else rest_api_id
939941

940942
@staticmethod
941-
def add_auth_to_swagger(
943+
def add_auth_to_swagger( # noqa: too-many-arguments
942944
event_auth: Dict[str, Any],
943945
api: Dict[str, Any],
944946
api_id: str,

samtranslator/model/role_utils/role_constructor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from samtranslator.model.resource_policies import PolicyTypes
55

66

7-
def construct_role_for_resource( # type: ignore[no-untyped-def]
7+
def construct_role_for_resource( # type: ignore[no-untyped-def] # noqa: too-many-arguments
88
resource_logical_id,
99
attributes,
1010
managed_policy_map,

samtranslator/model/sam_resources.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def]
298298

299299
return resources
300300

301-
def _construct_event_invoke_config(
301+
def _construct_event_invoke_config( # noqa: too-many-arguments
302302
self,
303303
function_name: str,
304304
alias_name: str,
@@ -931,7 +931,7 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV
931931

932932
return alias
933933

934-
def _validate_deployment_preference_and_add_update_policy(
934+
def _validate_deployment_preference_and_add_update_policy( # noqa: too-many-arguments
935935
self,
936936
deployment_preference_collection: DeploymentPreferenceCollection,
937937
lambda_alias: Optional[LambdaAlias],
@@ -1849,7 +1849,7 @@ def to_cloudformation(self, **kwargs: Any) -> List[Resource]: # type: ignore
18491849

18501850
raise InvalidResourceException(self.logical_id, "'Destination' is an empty list")
18511851

1852-
def generate_resources(
1852+
def generate_resources( # noqa: too-many-branches
18531853
self,
18541854
source: ConnectorResourceReference,
18551855
destination: ConnectorResourceReference,
@@ -1949,7 +1949,7 @@ def _get_policy_statements(self, profile: ConnectorProfile) -> Dict[str, Any]:
19491949
"Statement": policy_statements,
19501950
}
19511951

1952-
def _construct_iam_policy(
1952+
def _construct_iam_policy( # noqa: too-many-arguments
19531953
self,
19541954
source: ConnectorResourceReference,
19551955
destination: ConnectorResourceReference,

0 commit comments

Comments
 (0)