From f99f7cb24761ab9ff8949af200acf8470e3826ea Mon Sep 17 00:00:00 2001 From: Johan Tibell Date: Mon, 13 Mar 2023 14:40:30 +0100 Subject: [PATCH] Don't use NoReturn for methods that return None NoReturn are for methods that never return (e.g. always raise exceptions). Using NoReturn causes e.g. mypy to think all code following the call to the NoReturn method to be unreachable. Fixes #2002. --- aws_lambda_powertools/tracing/base.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/aws_lambda_powertools/tracing/base.py b/aws_lambda_powertools/tracing/base.py index d044817f920..6ea58da6b5a 100644 --- a/aws_lambda_powertools/tracing/base.py +++ b/aws_lambda_powertools/tracing/base.py @@ -2,7 +2,7 @@ import numbers import traceback from contextlib import contextmanager -from typing import Any, Generator, List, NoReturn, Optional, Sequence, Union +from typing import Any, Generator, List, Optional, Sequence, Union class BaseSegment(abc.ABC): @@ -28,7 +28,7 @@ def remove_subsegment(self, subsegment: Any): """Remove input subsegment from child subsegments.""" @abc.abstractmethod - def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> NoReturn: + def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> None: """Annotate segment or subsegment with a key-value pair. Note: Annotations will be indexed for later search query. @@ -42,7 +42,7 @@ def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> N """ @abc.abstractmethod - def put_metadata(self, key: str, value: Any, namespace: str = "default") -> NoReturn: + def put_metadata(self, key: str, value: Any, namespace: str = "default") -> None: """Add metadata to segment or subsegment. Metadata is not indexed but can be later retrieved by BatchGetTraces API. @@ -101,7 +101,7 @@ def in_subsegment_async(self, name=None, **kwargs) -> Generator[BaseSegment, Non """ @abc.abstractmethod - def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> NoReturn: + def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> None: """Annotate current active trace entity with a key-value pair. Note: Annotations will be indexed for later search query. @@ -115,7 +115,7 @@ def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> N """ @abc.abstractmethod - def put_metadata(self, key: str, value: Any, namespace: str = "default") -> NoReturn: + def put_metadata(self, key: str, value: Any, namespace: str = "default") -> None: """Add metadata to the current active trace entity. Note: Metadata is not indexed but can be later retrieved by BatchGetTraces API. @@ -131,7 +131,7 @@ def put_metadata(self, key: str, value: Any, namespace: str = "default") -> NoRe """ @abc.abstractmethod - def patch(self, modules: Sequence[str]) -> NoReturn: + def patch(self, modules: Sequence[str]) -> None: """Instrument a set of supported libraries Parameters @@ -141,5 +141,5 @@ def patch(self, modules: Sequence[str]) -> NoReturn: """ @abc.abstractmethod - def patch_all(self) -> NoReturn: + def patch_all(self) -> None: """Instrument all supported libraries"""