Skip to content

Commit

Permalink
chore: skip coverage on false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
heitorlessa committed May 7, 2024
1 parent 5634b30 commit efaa69e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion aws_lambda_powertools/event_handler/openapi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions aws_lambda_powertools/utilities/batch/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions aws_lambda_powertools/utilities/parser/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ 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

warnings.filterwarnings("ignore", category=PydanticDeprecationWarning)
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)

except ImportError:
except ImportError: # pragma: no cover # false positive; dropping in v3
pass
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit efaa69e

Please sign in to comment.