From c5cddbd0e33c86f9ca9ceb882f3ff4a3e7484168 Mon Sep 17 00:00:00 2001 From: Eric Nielsen <4120606+ericbn@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:04:26 -0500 Subject: [PATCH] refactor(jmespath_utils): add from __future__ import annotations and update code according to ruff rules TCH, UP006, UP007, UP037 and FA100. --- .../utilities/jmespath_utils/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aws_lambda_powertools/utilities/jmespath_utils/__init__.py b/aws_lambda_powertools/utilities/jmespath_utils/__init__.py index 22f04b60ffa..1bdff7a12ce 100644 --- a/aws_lambda_powertools/utilities/jmespath_utils/__init__.py +++ b/aws_lambda_powertools/utilities/jmespath_utils/__init__.py @@ -1,9 +1,11 @@ +from __future__ import annotations + import base64 import gzip import json import logging import warnings -from typing import Any, Dict, Optional, Union +from typing import Any import jmespath from jmespath.exceptions import LexerError @@ -33,7 +35,7 @@ def _func_powertools_base64_gzip(self, value): return uncompressed.decode() -def query(data: Union[Dict, str], envelope: str, jmespath_options: Optional[Dict] = None) -> Any: +def query(data: dict | str, envelope: str, jmespath_options: dict | None = None) -> Any: """Searches and extracts data using JMESPath Envelope being the JMESPath expression to extract the data you're after @@ -57,11 +59,11 @@ def handler(event: dict, context: LambdaContext): Parameters ---------- - data : Dict + data : dict | str Data set to be filtered envelope : str JMESPath expression to filter data against - jmespath_options : Dict + jmespath_options : dict | None Alternative JMESPath options to be included when filtering expr @@ -82,7 +84,7 @@ def handler(event: dict, context: LambdaContext): @deprecated("`extract_data_from_envelope` is deprecated; use `query` instead.", category=None) -def extract_data_from_envelope(data: Union[Dict, str], envelope: str, jmespath_options: Optional[Dict] = None) -> Any: +def extract_data_from_envelope(data: dict | str, envelope: str, jmespath_options: dict | None = None) -> Any: """Searches and extracts data using JMESPath *Deprecated*: Use query instead