Skip to content

refactor(jmespath_utils): add from __future__ import annotations #4962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from all 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
12 changes: 7 additions & 5 deletions aws_lambda_powertools/utilities/jmespath_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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


Expand All @@ -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
Expand Down
Loading