Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions aws_lambda_powertools/metrics/metric.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import logging
from contextlib import contextmanager
from typing import Dict, Optional, Union, Generator
from typing import Dict, Generator, Optional, Union

from .base import MetricManager, MetricUnit

Expand Down Expand Up @@ -61,7 +61,9 @@ def add_metric(self, name: str, unit: Union[MetricUnit, str], value: float) -> N


@contextmanager
def single_metric(name: str, unit: MetricUnit, value: float, namespace: Optional[str] = None) -> Generator[SingleMetric, None, None]:
def single_metric(
name: str, unit: MetricUnit, value: float, namespace: Optional[str] = None
) -> Generator[SingleMetric, None, None]:
"""Context manager to simplify creation of a single metric

Example
Expand Down
4 changes: 2 additions & 2 deletions aws_lambda_powertools/utilities/parameters/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _get(self, name: str, **sdk_options) -> str:
sdk_options["ClientId"] = CLIENT_ID

response = self.client.get_configuration(**sdk_options)
return response["Content"].read() # read() of botocore.response.StreamingBody
return response["Content"].read().decode("utf-8") # read() of botocore.response.StreamingBody

def _get_multiple(self, path: str, **sdk_options) -> Dict[str, str]:
"""
Expand All @@ -121,7 +121,7 @@ def get_app_config(
force_fetch: bool = False,
max_age: int = DEFAULT_MAX_AGE_SECS,
**sdk_options
) -> Union[str, list, dict, bytes]:
) -> Union[str, list, dict]:
"""
Retrieve a configuration value from AWS App Config.

Expand Down
5 changes: 2 additions & 3 deletions tests/functional/test_utilities_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,9 +1503,8 @@ def test_appconf_provider_get_configuration_no_transform(mock_name, config):
stubber.activate()

try:
value = provider.get(mock_name)
str_value = value.decode("utf-8")
assert str_value == json.dumps(mock_body_json)
value: str = provider.get(mock_name)
assert value == json.dumps(mock_body_json)
stubber.assert_no_pending_responses()
finally:
stubber.deactivate()
Expand Down