Skip to content

Commit f6fe29e

Browse files
committed
fix(mypy): use sequence and update mypy.init
1 parent 02fc79b commit f6fe29e

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

aws_lambda_powertools/tracing/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class BaseProvider(abc.ABC):
9-
@abc.abstractmethod
9+
@abc.abstractmethod # type: ignore
1010
@contextmanager
1111
def in_subsegment(self, name=None, **kwargs) -> ContextManager:
1212
"""Return a subsegment context manger.
@@ -19,7 +19,7 @@ def in_subsegment(self, name=None, **kwargs) -> ContextManager:
1919
Optional parameters to be propagated to segment
2020
"""
2121

22-
@abc.abstractmethod
22+
@abc.abstractmethod # type: ignore
2323
@contextmanager
2424
def in_subsegment_async(self, name=None, **kwargs) -> AsyncContextManager:
2525
"""Return a subsegment async context manger.

aws_lambda_powertools/tracing/tracer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
import numbers
77
import os
8-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
8+
from typing import Any, Callable, Dict, Optional, Sequence, Union
99

1010
from ..shared import constants
1111
from ..shared.functions import resolve_env_var_choice, resolve_truthy_env_var_choice
@@ -53,7 +53,7 @@ class Tracer:
5353
disabled: bool
5454
Flag to explicitly disable tracing, useful when running/testing locally
5555
`Env POWERTOOLS_TRACE_DISABLED="true"`
56-
patch_modules: Tuple[str]
56+
patch_modules: Optional[Sequence[str]]
5757
Tuple of modules supported by tracing provider to patch, by default all modules are patched
5858
provider: BaseProvider
5959
Tracing provider, by default it is aws_xray_sdk.core.xray_recorder
@@ -149,7 +149,7 @@ def __init__(
149149
service: Optional[str] = None,
150150
disabled: Optional[bool] = None,
151151
auto_patch: Optional[bool] = None,
152-
patch_modules: Optional[Tuple[str]] = None,
152+
patch_modules: Optional[Sequence[str]] = None,
153153
provider: Optional[BaseProvider] = None,
154154
):
155155
self.__build_config(
@@ -223,14 +223,14 @@ def put_metadata(self, key: str, value: Any, namespace: Optional[str] = None):
223223
logger.debug(f"Adding metadata on key '{key}' with '{value}' at namespace '{namespace}'")
224224
self.provider.put_metadata(key=key, value=value, namespace=namespace)
225225

226-
def patch(self, modules: Optional[Tuple[str]] = None):
226+
def patch(self, modules: Optional[Sequence[str]] = None):
227227
"""Patch modules for instrumentation.
228228
229229
Patches all supported modules by default if none are given.
230230
231231
Parameters
232232
----------
233-
modules : Tuple[str]
233+
modules : Optional[Sequence[str]]
234234
List of modules to be patched, optional by default
235235
"""
236236
if self.disabled:
@@ -720,7 +720,7 @@ def __build_config(
720720
service: Optional[str] = None,
721721
disabled: Optional[bool] = None,
722722
auto_patch: Optional[bool] = None,
723-
patch_modules: Optional[Union[List, Tuple]] = None,
723+
patch_modules: Optional[Sequence[str]] = None,
724724
provider: Optional[BaseProvider] = None,
725725
):
726726
"""Populates Tracer config for new and existing initializations"""

mypy.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,18 @@ show_error_context = True
1111

1212
[mypy-jmespath]
1313
ignore_missing_imports=True
14+
15+
[mypy-boto3]
16+
ignore_missing_imports = True
17+
18+
[mypy-boto3.dynamodb.conditions]
19+
ignore_missing_imports = True
20+
21+
[mypy-botocore.config]
22+
ignore_missing_imports = True
23+
24+
[mypy-botocore.exceptions]
25+
ignore_missing_imports = True
26+
27+
[mypy-aws_xray_sdk.ext.aiohttp.client]
28+
ignore_missing_imports = True

0 commit comments

Comments
 (0)