aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mbaruh <[email protected]>2023-02-27 21:53:41 +0200
committerGravatar mbaruh <[email protected]>2023-02-27 21:53:41 +0200
commit12e1e3771309bf7a39131687984d54859c691c9d (patch)
tree9adfb593504614558b32c885ba9090abaef8e865
parentCreate a guide for developing the filtering ext (diff)
Simplify `Settings.copy`
Co-authored-by: Ionite <[email protected]>
-rw-r--r--bot/exts/filtering/_settings.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/bot/exts/filtering/_settings.py b/bot/exts/filtering/_settings.py
index a752918a6..fff4239ec 100644
--- a/bot/exts/filtering/_settings.py
+++ b/bot/exts/filtering/_settings.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import operator
import traceback
from abc import abstractmethod
+from copy import copy
from functools import reduce
from typing import Any, NamedTuple, Optional, TypeVar
@@ -105,9 +106,7 @@ class Settings(FieldRequiring, dict[str, T]):
def copy(self: TSettings) -> TSettings:
"""Create a shallow copy of the object."""
- copy = self.__class__({})
- copy.update(super().copy()) # Copy the internal dict.
- return copy
+ return copy(self)
def get_setting(self, key: str, default: Optional[Any] = None) -> Any:
"""Get the setting matching the key, or fall back to the default value if the key is missing."""