Skip to content

Commit a57bbfd

Browse files
refactor(jmespath_utils): add from __future__ import annotations (#4962)
and update code according to ruff rules TCH, UP006, UP007, UP037 and FA100. Co-authored-by: Leandro Damascena <[email protected]>
1 parent 423b00a commit a57bbfd

File tree

1 file changed

+7
-5
lines changed
  • aws_lambda_powertools/utilities/jmespath_utils

1 file changed

+7
-5
lines changed

aws_lambda_powertools/utilities/jmespath_utils/__init__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from __future__ import annotations
2+
13
import base64
24
import gzip
35
import json
46
import logging
57
import warnings
6-
from typing import Any, Dict, Optional, Union
8+
from typing import Any
79

810
import jmespath
911
from jmespath.exceptions import LexerError
@@ -33,7 +35,7 @@ def _func_powertools_base64_gzip(self, value):
3335
return uncompressed.decode()
3436

3537

36-
def query(data: Union[Dict, str], envelope: str, jmespath_options: Optional[Dict] = None) -> Any:
38+
def query(data: dict | str, envelope: str, jmespath_options: dict | None = None) -> Any:
3739
"""Searches and extracts data using JMESPath
3840
3941
Envelope being the JMESPath expression to extract the data you're after
@@ -57,11 +59,11 @@ def handler(event: dict, context: LambdaContext):
5759
5860
Parameters
5961
----------
60-
data : Dict
62+
data : dict | str
6163
Data set to be filtered
6264
envelope : str
6365
JMESPath expression to filter data against
64-
jmespath_options : Dict
66+
jmespath_options : dict | None
6567
Alternative JMESPath options to be included when filtering expr
6668
6769
@@ -82,7 +84,7 @@ def handler(event: dict, context: LambdaContext):
8284

8385

8486
@deprecated("`extract_data_from_envelope` is deprecated; use `query` instead.", category=None)
85-
def extract_data_from_envelope(data: Union[Dict, str], envelope: str, jmespath_options: Optional[Dict] = None) -> Any:
87+
def extract_data_from_envelope(data: dict | str, envelope: str, jmespath_options: dict | None = None) -> Any:
8688
"""Searches and extracts data using JMESPath
8789
8890
*Deprecated*: Use query instead

0 commit comments

Comments
 (0)