File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,8 @@ def class_decorator(cls):
16
16
if not private_methods :
17
17
continue
18
18
19
- elif attr_name .startswith ("_" ):
20
- if not protected_methods :
21
- continue
19
+ elif attr_name .startswith ("_" ) and not protected_methods :
20
+ continue
22
21
23
22
# Replace the original callable with the decorated version
24
23
setattr (cls , attr_name , decorator (attr_value ))
Original file line number Diff line number Diff line change 6
6
7
7
from common .tracing import trace_function
8
8
from common .utils import apply_decorator_to_methods
9
+
9
10
from ._gateway_interfaces import BookEventGatewayInterface , BookRepositoryInterface
10
11
from ._models import BookModel
11
12
from ._tasks import book_cpu_intensive_task
Original file line number Diff line number Diff line change 8
8
@pytest .mark .parametrize (
9
9
"apply_to_protected_methods" ,
10
10
[
11
- True ,
12
- False ,
11
+ pytest . param ( True , id = "protected_methods" ) ,
12
+ pytest . param ( False , id = "no_protected_methods" ) ,
13
13
],
14
14
)
15
15
@pytest .mark .parametrize (
16
16
"apply_to_private_methods" ,
17
17
[
18
- True ,
19
- False ,
18
+ pytest . param ( True , id = "private_methods" ) ,
19
+ pytest . param ( False , id = "no_private_methods" ) ,
20
20
],
21
21
)
22
22
async def test_class_decorator (
@@ -61,7 +61,7 @@ async def __get_aprivate(self):
61
61
c = MyClass ()
62
62
assert c .get_public () == 20
63
63
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
65
65
assert await c .get_apublic () == 20
66
66
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
You can’t perform that action at this time.
0 commit comments