Skip to content

Commit 49732be

Browse files
committed
Revert "Attempt to reduce cognitive complexity"
This reverts commit 2d4d670.
1 parent b995b09 commit 49732be

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/common/utils.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,21 @@ def apply_decorator_to_methods(
66
to all functions and coroutines within a class.
77
"""
88

9-
def is_private_method(attr_name, cls_name):
10-
"""Check if the attribute is a private method."""
11-
return attr_name.startswith(f"_{cls_name}__")
12-
13-
def is_protected_method(attr_name, cls_name):
14-
"""Check if the attribute is a protected method."""
15-
return attr_name.startswith("_") and not attr_name.startswith(f"_{cls_name}__")
16-
179
def class_decorator(cls):
18-
cls_name = cls.__name__
19-
2010
for attr_name, attr_value in cls.__dict__.items():
21-
# Skip attributes that are not callable
11+
# Check if the attribute is a callable (method or coroutine)
2212
if not callable(attr_value):
2313
continue
2414

25-
# Check for private methods
26-
if is_private_method(attr_name, cls_name):
15+
if attr_name.startswith(f"_{cls.__name__}__"):
2716
if not private_methods:
2817
continue
2918

30-
# Check for protected methods
31-
elif is_protected_method(attr_name, cls_name) and not protected_methods:
19+
elif attr_name.startswith("_") and not protected_methods:
3220
continue
3321

3422
# Replace the original callable with the decorated version
3523
setattr(cls, attr_name, decorator(attr_value))
36-
3724
return cls
3825

3926
return class_decorator

0 commit comments

Comments
 (0)