Skip to content

Commit

Permalink
chore: remove mutable property
Browse files Browse the repository at this point in the history
  • Loading branch information
salman2013 committed Mar 15, 2024
1 parent 9e9a8d1 commit 3698982
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
15 changes: 2 additions & 13 deletions xblock/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ class will want to refer to.
runtime_options.
"""
MUTABLE = True
_default = None
# Indicates if a field's None value should be sent to the XML representation.
none_to_xml = False
Expand All @@ -334,10 +333,7 @@ def __init__(self, help=None, default=UNSET, scope=Scope.content, # pylint:disa
@property
def default(self):
"""Returns the static value that this defaults to."""
if self.MUTABLE:
return copy.deepcopy(self._default)
else:
return self._default
return copy.deepcopy(self._default)

@property
def name(self):
Expand Down Expand Up @@ -516,10 +512,7 @@ def __get__(self, xblock, xblock_class):
value = self.default
self._set_cached_value(xblock, value)

# If this is a mutable type, mark it as dirty, since mutations can occur without an
# explicit call to __set__ (but they do require a call to __get__)
if self.MUTABLE:
self._mark_dirty(xblock, value)
self._mark_dirty(xblock, value)

return self._sanitize(value)

Expand Down Expand Up @@ -701,7 +694,6 @@ class Integer(JSONField):
containing a floating point number ('3.48') will throw an error.
"""
MUTABLE = False

def from_json(self, value):
if value is None or value == '':
Expand All @@ -720,7 +712,6 @@ class Float(JSONField):
something for which float(value) does not throw an error.
"""
MUTABLE = False

def from_json(self, value):
if value is None or value == '':
Expand Down Expand Up @@ -750,7 +741,6 @@ class Boolean(JSONField):
None - > False
"""
MUTABLE = False

# We're OK redefining built-in `help`
def __init__(self, help=None, default=UNSET, scope=Scope.content, display_name=None,
Expand Down Expand Up @@ -853,7 +843,6 @@ class String(JSONField):
The value, as loaded or enforced, can either be None or a basestring instance.
"""
MUTABLE = False
BAD_REGEX = re.compile('[\x00-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]', flags=re.UNICODE)

def _sanitize(self, value):
Expand Down
1 change: 0 additions & 1 deletion xblock/reference/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class Filesystem(Field):
src=...> will typically be faster through this than serving that
up through XBlocks views.
"""
MUTABLE = False

def __get__(self, xblock, xblock_class):
"""
Expand Down

0 comments on commit 3698982

Please sign in to comment.