From efaa69e591c3f1f7449be68efdc774d540a18ade Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Tue, 7 May 2024 10:50:27 +0200 Subject: [PATCH] chore: skip coverage on false positives --- aws_lambda_powertools/event_handler/api_gateway.py | 6 +++--- aws_lambda_powertools/event_handler/openapi/compat.py | 2 +- .../event_handler/openapi/pydantic_loader.py | 2 +- aws_lambda_powertools/utilities/batch/types.py | 4 ++-- aws_lambda_powertools/utilities/parser/compat.py | 4 ++-- pyproject.toml | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/aws_lambda_powertools/event_handler/api_gateway.py b/aws_lambda_powertools/event_handler/api_gateway.py index ce767e8a4ee..18e0475395c 100644 --- a/aws_lambda_powertools/event_handler/api_gateway.py +++ b/aws_lambda_powertools/event_handler/api_gateway.py @@ -1646,13 +1646,13 @@ def _determine_openapi_version(openapi_version): from aws_lambda_powertools.event_handler.openapi.pydantic_loader import PYDANTIC_V2 # Pydantic V2 has no support for OpenAPI schema 3.0 - if PYDANTIC_V2 and not openapi_version.startswith("3.1"): + if PYDANTIC_V2 and not openapi_version.startswith("3.1"): # pragma: no cover warnings.warn( "You are using Pydantic v2, which is incompatible with OpenAPI schema 3.0. Forcing OpenAPI 3.1", stacklevel=2, ) openapi_version = "3.1.0" - elif not PYDANTIC_V2 and not openapi_version.startswith("3.0"): + elif not PYDANTIC_V2 and not openapi_version.startswith("3.0"): # pragma: no cover warnings.warn( "You are using Pydantic v1, which is incompatible with OpenAPI schema 3.1. Forcing OpenAPI 3.0", stacklevel=2, @@ -2192,7 +2192,7 @@ def not_found(self, func: Optional[Callable] = None): def exception_handler(self, exc_class: Union[Type[Exception], List[Type[Exception]]]): def register_exception_handler(func: Callable): - if isinstance(exc_class, list): + if isinstance(exc_class, list): # pragma: no cover for exp in exc_class: self._exception_handlers[exp] = func else: diff --git a/aws_lambda_powertools/event_handler/openapi/compat.py b/aws_lambda_powertools/event_handler/openapi/compat.py index bd102aa7b93..060886605ec 100644 --- a/aws_lambda_powertools/event_handler/openapi/compat.py +++ b/aws_lambda_powertools/event_handler/openapi/compat.py @@ -40,7 +40,7 @@ RequestErrorModel: Type[BaseModel] = create_model("Request") -if PYDANTIC_V2: +if PYDANTIC_V2: # pragma: no cover # false positive; dropping in v3 from pydantic import TypeAdapter, ValidationError from pydantic._internal._typing_extra import eval_type_lenient from pydantic.fields import FieldInfo diff --git a/aws_lambda_powertools/event_handler/openapi/pydantic_loader.py b/aws_lambda_powertools/event_handler/openapi/pydantic_loader.py index 12f06dad899..225f7e88096 100644 --- a/aws_lambda_powertools/event_handler/openapi/pydantic_loader.py +++ b/aws_lambda_powertools/event_handler/openapi/pydantic_loader.py @@ -3,4 +3,4 @@ PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.") except ImportError: - PYDANTIC_V2 = False + PYDANTIC_V2 = False # pragma: no cover # false positive; dropping in v3 diff --git a/aws_lambda_powertools/utilities/batch/types.py b/aws_lambda_powertools/utilities/batch/types.py index 40083537e04..d48f768a6b8 100644 --- a/aws_lambda_powertools/utilities/batch/types.py +++ b/aws_lambda_powertools/utilities/batch/types.py @@ -7,7 +7,7 @@ # For IntelliSense and Mypy to work, we need to account for possible SQS subclasses # We need them as subclasses as we must access their message ID or sequence number metadata via dot notation -if has_pydantic: +if has_pydantic: # pragma: no cover from aws_lambda_powertools.utilities.parser.models import DynamoDBStreamRecordModel, SqsRecordModel from aws_lambda_powertools.utilities.parser.models import ( KinesisDataStreamRecord as KinesisDataStreamRecordModel, @@ -17,7 +17,7 @@ Union[Type[SqsRecordModel], Type[DynamoDBStreamRecordModel], Type[KinesisDataStreamRecordModel]] ] BatchSqsTypeModel = Optional[Type[SqsRecordModel]] -else: +else: # pragma: no cover BatchTypeModels = "BatchTypeModels" # type: ignore BatchSqsTypeModel = "BatchSqsTypeModel" # type: ignore diff --git a/aws_lambda_powertools/utilities/parser/compat.py b/aws_lambda_powertools/utilities/parser/compat.py index c73098421b1..c76bc6546a5 100644 --- a/aws_lambda_powertools/utilities/parser/compat.py +++ b/aws_lambda_powertools/utilities/parser/compat.py @@ -22,7 +22,7 @@ def disable_pydantic_v2_warning(): version = __version__.split(".") - if int(version[0]) == 2: + if int(version[0]) == 2: # pragma: no cover # dropping in v3 import warnings from pydantic import PydanticDeprecatedSince20, PydanticDeprecationWarning @@ -30,5 +30,5 @@ def disable_pydantic_v2_warning(): warnings.filterwarnings("ignore", category=PydanticDeprecationWarning) warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20) - except ImportError: + except ImportError: # pragma: no cover # false positive; dropping in v3 pass diff --git a/pyproject.toml b/pyproject.toml index 5109a00c8d1..4c868784632 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,6 +129,7 @@ omit = [ "aws_lambda_powertools/exceptions/*", "aws_lambda_powertools/utilities/parser/types.py", "aws_lambda_powertools/utilities/jmespath_utils/envelopes.py", + "aws_lambda_powertools/metrics/metric.py" # barrel import (export-only) ] branch = true