Skip to content

Commit 15dde95

Browse files
committed
improve decorate_all_methods to skip dunder methods
1 parent 742fb87 commit 15dde95

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

django_valkey/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@
3333
def decorate_all_methods(decorator):
3434
def decorate(cls):
3535
for attr in vars(cls):
36+
# dunders and `get` should not be decorated
37+
# get is handled by `_get`
38+
if attr.startswith("__") or attr in {"get", "get_or_set"}:
39+
continue
40+
3641
attribute = getattr(cls, attr)
3742
if callable(attribute):
38-
if attr == "get" or attr == "get_or_set":
39-
continue
40-
elif attr == "_get":
43+
if attr == "_get":
4144
setattr(
4245
cls,
4346
attr,

0 commit comments

Comments
 (0)