Skip to content

Commit 0fadae5

Browse files
committed
Lint and typing
1 parent 695a961 commit 0fadae5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/common/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ def class_decorator(cls):
1616
if not private_methods:
1717
continue
1818

19-
elif attr_name.startswith("_"):
20-
if not protected_methods:
21-
continue
19+
elif attr_name.startswith("_") and not protected_methods:
20+
continue
2221

2322
# Replace the original callable with the decorated version
2423
setattr(cls, attr_name, decorator(attr_value))

src/domains/books/_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from common.tracing import trace_function
88
from common.utils import apply_decorator_to_methods
9+
910
from ._gateway_interfaces import BookEventGatewayInterface, BookRepositoryInterface
1011
from ._models import BookModel
1112
from ._tasks import book_cpu_intensive_task

tests/common/test_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
@pytest.mark.parametrize(
99
"apply_to_protected_methods",
1010
[
11-
True,
12-
False,
11+
pytest.param(True, id="protected_methods"),
12+
pytest.param(False, id="no_protected_methods"),
1313
],
1414
)
1515
@pytest.mark.parametrize(
1616
"apply_to_private_methods",
1717
[
18-
True,
19-
False,
18+
pytest.param(True, id="private_methods"),
19+
pytest.param(False, id="no_private_methods"),
2020
],
2121
)
2222
async def test_class_decorator(
@@ -61,7 +61,7 @@ async def __get_aprivate(self):
6161
c = MyClass()
6262
assert c.get_public() == 20
6363
assert c._get_protected() == 20 if apply_to_protected_methods else 10
64-
assert c._MyClass__get_private() == 20 if apply_to_private_methods else 10
64+
assert c._MyClass__get_private() == 20 if apply_to_private_methods else 10 # type: ignore
6565
assert await c.get_apublic() == 20
6666
assert await c._get_aprotected() == 20 if apply_to_protected_methods else 10
67-
assert await c._MyClass__get_aprivate() == 20 if apply_to_private_methods else 10
67+
assert await c._MyClass__get_aprivate() == 20 if apply_to_private_methods else 10 # type: ignore

0 commit comments

Comments
 (0)