Skip to content

Commit 85d5253

Browse files
authored
refactor(typing): enable TCH, UP and FA100 ruff rules (#5017)
* refactor(typing): enable TCH, UP and FA100 ruff rules * Fix missing ruff error TCH002 from data_classes
1 parent c865449 commit 85d5253

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+63
-82
lines changed

aws_lambda_powertools/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Top-level package for Lambda Python Powertools."""
42

53
from pathlib import Path

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ def route(
18701870

18711871
def register_resolver(func: Callable):
18721872
methods = (method,) if isinstance(method, str) else method
1873-
logger.debug(f"Adding route using rule {rule} and methods: {','.join((m.upper() for m in methods))}")
1873+
logger.debug(f"Adding route using rule {rule} and methods: {','.join(m.upper() for m in methods)}")
18741874

18751875
cors_enabled = self._cors_enabled if cors is None else cors
18761876

aws_lambda_powertools/event_handler/bedrock_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get( # type: ignore[override]
109109
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
110110
security = None
111111

112-
return super(BedrockAgentResolver, self).get(
112+
return super().get(
113113
rule,
114114
cors,
115115
compress,

aws_lambda_powertools/event_handler/openapi/params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def __init__(
328328
if default is not ...:
329329
raise AssertionError("Path parameters cannot have a default value")
330330

331-
super(Path, self).__init__(
331+
super().__init__(
332332
default=default,
333333
default_factory=default_factory,
334334
annotation=annotation,

aws_lambda_powertools/event_handler/openapi/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import types
44
from enum import Enum
5-
from typing import Any, Callable, Dict, Set, Type, TypedDict, Union
5+
from typing import TYPE_CHECKING, Any, Callable, Dict, Set, Type, TypedDict, Union
66

77
from pydantic import BaseModel
8-
from typing_extensions import NotRequired
8+
9+
if TYPE_CHECKING:
10+
from typing_extensions import NotRequired
911

1012
CacheKey = Union[Callable[..., Any], None]
1113
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]]

aws_lambda_powertools/logging/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

3-
from typing import Any, Dict, TypedDict, Union
3+
from typing import TYPE_CHECKING, Any, Dict, TypedDict, Union
44

5-
from typing_extensions import NotRequired, TypeAlias
5+
if TYPE_CHECKING:
6+
from typing_extensions import NotRequired, TypeAlias
67

78

89
class PowertoolsLogRecord(TypedDict):

aws_lambda_powertools/metrics/provider/cloudwatch_emf/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

3-
from typing import TypedDict
3+
from typing import TYPE_CHECKING, TypedDict
44

5-
from typing_extensions import NotRequired
5+
if TYPE_CHECKING:
6+
from typing_extensions import NotRequired
67

78

89
class CloudWatchEMFMetric(TypedDict):

aws_lambda_powertools/shared/cache_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __setitem__(self, key, value):
2525
del self[oldest]
2626

2727
def get(self, key, *args, **kwargs):
28-
item = super(LRUDict, self).get(key, *args, **kwargs)
28+
item = super().get(key, *args, **kwargs)
2929
if item:
3030
self.move_to_end(key=key)
3131
return item

aws_lambda_powertools/shared/lazy_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, local_name, parent_module_globals, name): # pylint: disable=
3232
self._local_name = local_name
3333
self._parent_module_globals = parent_module_globals
3434

35-
super(LazyLoader, self).__init__(name)
35+
super().__init__(name)
3636

3737
def _load(self):
3838
# Import the target module and insert it into the parent's namespace
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""General utilities for Powertools"""

0 commit comments

Comments
 (0)