Skip to content

Commit 1593d4a

Browse files
committed
Make copy of list class attrs
1 parent 1329f55 commit 1593d4a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bolt-admin/bolt/admin/views/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ def get_objects(self) -> list:
168168
return []
169169

170170
def get_fields(self) -> list:
171-
return self.fields
171+
return (
172+
self.fields.copy()
173+
) # Avoid mutating the class attribute if using append etc
172174

173175
def get_actions(self) -> dict[str]:
174-
return self.actions
176+
return self.actions.copy() # Avoid mutating the class attribute itself
175177

176178
def get_filters(self) -> list[str]:
177-
return self.filters
179+
return self.filters.copy() # Avoid mutating the class attribute itself
178180

179181
def get_object_field(self, obj, field: str):
180182
# Try basic dict lookup first

0 commit comments

Comments
 (0)