Skip to content

Commit

Permalink
Make copy of list class attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Jan 10, 2024
1 parent 1329f55 commit 1593d4a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bolt-admin/bolt/admin/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ def get_objects(self) -> list:
return []

def get_fields(self) -> list:
return self.fields
return (
self.fields.copy()
) # Avoid mutating the class attribute if using append etc

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

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

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

0 comments on commit 1593d4a

Please sign in to comment.