Skip to content

Commit

Permalink
chore: fix linting on loop variable
Browse files Browse the repository at this point in the history
Signed-off-by: heitorlessa <[email protected]>
  • Loading branch information
heitorlessa committed Dec 20, 2023
1 parent 65b3d6a commit e0f4a3a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions aws_lambda_powertools/utilities/_data_masking/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
import functools

import functools
import logging
from numbers import Number
from typing import Any, Callable, Mapping, Optional, Sequence, Union, overload
Expand Down Expand Up @@ -222,6 +222,16 @@ def _apply_action_to_fields(

data_parsed: dict = self._normalize_data_to_parse(fields, data)

# For in-place updates, json_parse accepts a callback function
# this function must receive 3 args: field_value, fields, field_name
# We create a partial callback to pre-populate known options (action, provider opts, enc ctx)
update_callback = functools.partial(
self._call_action,
action=action,
provider_options=provider_options,
**encryption_context,
)

# Iterate over each field to be parsed.
for field_parse in fields:
# Parse the field expression using a 'parse' function.
Expand All @@ -236,14 +246,9 @@ def _apply_action_to_fields(
if not result_parse:
raise DataMaskingFieldNotFoundError(f"Field or expression {field_parse} not found in {data_parsed}")

# For in-place updates, json_parse accepts a callback function that receives 3 args: field_value, fields, field_name
# We create a partial callback to pre-populate known provider options (action, provider opts, enc ctx)
update_callback = functools.partial(
self._call_action, action=action, provider_options=provider_options, **encryption_context
)

json_parse.update(
data_parsed, lambda field_value, fields, field_name: update_callback(field_value, fields, field_name)
data_parsed,
lambda field_value, fields, field_name: update_callback(field_value, fields, field_name),
)

return data_parsed
Expand Down

0 comments on commit e0f4a3a

Please sign in to comment.