Skip to content

Commit 95d8eda

Browse files
chore(ci): drop support for Python 3.7 (#3638)
* Python 3.7 deprecation + cleaning code with unnecessary compats * Ops, missing a file * Ops, missing a file * Reverting a potential breaking change * Refactoring data class to cache some properties * Importing from typing_extensions directly * Reverting * Addressing Heitor's feedback --------- Co-authored-by: Heitor Lessa <[email protected]>
1 parent 190e9a9 commit 95d8eda

39 files changed

+67
-436
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ body:
5858
attributes:
5959
label: AWS Lambda function runtime
6060
options:
61-
- "3.7"
6261
- "3.8"
6362
- "3.9"
6463
- "3.10"

.github/ISSUE_TEMPLATE/static_typing.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ body:
2525
attributes:
2626
label: AWS Lambda function runtime
2727
options:
28-
- "3.7"
2928
- "3.8"
3029
- "3.9"
3130
- "3.10"

.github/workflows/quality_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
strategy:
4545
max-parallel: 4
4646
matrix:
47-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
47+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
4848
env:
4949
PYTHON: "${{ matrix.python-version }}"
5050
permissions:

.github/workflows/quality_check_pydanticv2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
max-parallel: 4
4545
matrix:
46-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
46+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
4747
env:
4848
PYTHON: "${{ matrix.python-version }}"
4949
permissions:

.github/workflows/run-e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
fail-fast: false # needed so if a version fails, the others will still be able to complete and cleanup
4949
matrix:
50-
version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
50+
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
5151
if: ${{ github.actor != 'dependabot[bot]' && github.repository == 'aws-powertools/powertools-lambda-python' }}
5252
steps:
5353
- name: "Checkout"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Build](https://github.com/aws-powertools/powertools-lambda-python/actions/workflows/quality_check.yml/badge.svg)](https://github.com/aws-powertools/powertools-lambda-python/actions/workflows/python_build.yml)
55
[![codecov.io](https://codecov.io/github/aws-powertools/powertools-lambda-python/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/aws-powertools/powertools-lambda-python)
6-
![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.7|%203.8|%203.9|%203.10|%203.11|%203.12&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python/badge)](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET)
6+
![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.8|%203.9|%203.10|%203.11|%203.12&color=blue?style=flat-square&logo=python) ![PyPI version](https://badge.fury.io/py/aws-lambda-powertools.svg) ![PyPi monthly downloads](https://img.shields.io/pypi/dm/aws-lambda-powertools) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python/badge)](https://api.securityscorecards.dev/projects/github.com/aws-powertools/powertools-lambda-python) [![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET)
77

88
Powertools for AWS Lambda (Python) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/python/latest/#features).
99

aws_lambda_powertools/logging/compat.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

aws_lambda_powertools/logging/logger.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
overload,
2323
)
2424

25-
from aws_lambda_powertools.logging import compat
2625
from aws_lambda_powertools.shared import constants
2726
from aws_lambda_powertools.shared.functions import (
2827
extract_event_from_common_models,
@@ -302,9 +301,6 @@ def _init_logger(
302301
self.addHandler(self.logger_handler)
303302
self.structure_logs(formatter_options=formatter_options, **kwargs)
304303

305-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
306-
self._logger.findCaller = compat.findCaller # type: ignore[method-assign]
307-
308304
# Pytest Live Log feature duplicates log records for colored output
309305
# but we explicitly add a filter for log deduplication.
310306
# This flag disables this protection when you explicit want logs to be duplicated (#262)
@@ -467,9 +463,6 @@ def info(
467463
extra = extra or {}
468464
extra = {**extra, **kwargs}
469465

470-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
471-
if sys.version_info < (3, 8): # pragma: no cover
472-
return self._logger.info(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra)
473466
return self._logger.info(
474467
msg,
475468
*args,
@@ -492,9 +485,6 @@ def error(
492485
extra = extra or {}
493486
extra = {**extra, **kwargs}
494487

495-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
496-
if sys.version_info < (3, 8): # pragma: no cover
497-
return self._logger.error(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra)
498488
return self._logger.error(
499489
msg,
500490
*args,
@@ -517,9 +507,6 @@ def exception(
517507
extra = extra or {}
518508
extra = {**extra, **kwargs}
519509

520-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
521-
if sys.version_info < (3, 8): # pragma: no cover
522-
return self._logger.exception(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra)
523510
return self._logger.exception(
524511
msg,
525512
*args,
@@ -542,9 +529,6 @@ def critical(
542529
extra = extra or {}
543530
extra = {**extra, **kwargs}
544531

545-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
546-
if sys.version_info < (3, 8): # pragma: no cover
547-
return self._logger.critical(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra)
548532
return self._logger.critical(
549533
msg,
550534
*args,
@@ -567,9 +551,6 @@ def warning(
567551
extra = extra or {}
568552
extra = {**extra, **kwargs}
569553

570-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
571-
if sys.version_info < (3, 8): # pragma: no cover
572-
return self._logger.warning(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra)
573554
return self._logger.warning(
574555
msg,
575556
*args,
@@ -592,9 +573,6 @@ def debug(
592573
extra = extra or {}
593574
extra = {**extra, **kwargs}
594575

595-
# Maintenance: We can drop this upon Py3.7 EOL. It's a backport for "location" key to work
596-
if sys.version_info < (3, 8): # pragma: no cover
597-
return self._logger.debug(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra)
598576
return self._logger.debug(
599577
msg,
600578
*args,

aws_lambda_powertools/shared/types.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import sys
2-
from typing import Any, Callable, Dict, List, TypeVar, Union
3-
4-
if sys.version_info >= (3, 8):
5-
from typing import Literal, Protocol, TypedDict
6-
else:
7-
from typing_extensions import Literal, Protocol, TypedDict
2+
from typing import Any, Callable, Dict, List, Literal, Protocol, TypedDict, TypeVar, Union
83

94
if sys.version_info >= (3, 9):
105
from typing import Annotated
@@ -16,7 +11,6 @@
1611
else:
1712
from typing_extensions import NotRequired
1813

19-
2014
# Even though `get_args` and `get_origin` were added in Python 3.8, they only handle Annotated correctly on 3.10.
2115
# So for python < 3.10 we use the backport from typing_extensions.
2216
if sys.version_info >= (3, 10):

aws_lambda_powertools/utilities/data_classes/active_mq_event.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from functools import cached_property
12
from typing import Any, Dict, Iterator, Optional
23

34
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper
@@ -23,12 +24,9 @@ def decoded_data(self) -> str:
2324
"""Decodes the data as a str"""
2425
return base64_decode(self.data)
2526

26-
@property
27+
@cached_property
2728
def json_data(self) -> Any:
28-
"""Parses the data as json"""
29-
if self._json_data is None:
30-
self._json_data = self._json_deserializer(self.decoded_data)
31-
return self._json_data
29+
return self._json_deserializer(self.decoded_data)
3230

3331
@property
3432
def connection_id(self) -> str:

0 commit comments

Comments
 (0)