diff --git a/mutalyzer/config/__init__.py b/mutalyzer/config/__init__.py index 4d8d99403ad7d8ba05016ba97fa42a2741667310..0ca16a759d6c2c9391cebb106a401e1b06e9900a 100644 --- a/mutalyzer/config/__init__.py +++ b/mutalyzer/config/__init__.py @@ -68,7 +68,7 @@ class LazySettings(util.LazyObject): """ Called to manually configure the settings. """ - if self._wrapped is None: + if self._wrapped is util.empty: self._setup(from_environment=False) self._wrapped.update(settings) @@ -87,7 +87,7 @@ class LazySettings(util.LazyObject): """ Returns True if the settings have already been configured. """ - return self._wrapped is not None + return self._wrapped is not util.empty def on_update(self, callback, key=None): """ diff --git a/mutalyzer/util.py b/mutalyzer/util.py index a367f31b6e8798af747a24bc2df56ee1ae018391..702584c03974c9e67d17dcdbb628c651fd966a69 100644 --- a/mutalyzer/util.py +++ b/mutalyzer/util.py @@ -917,10 +917,14 @@ class AttributeDictMixin(object): self[key] = value +# This is used in LazyObject to define the empty wrapper. +empty = object() + + # Helper for LazyObject. def _new_method_proxy(func): def inner(self, *args): - if self._wrapped is None: + if self._wrapped is empty: self._setup() return func(self._wrapped, *args) return inner @@ -937,7 +941,7 @@ class LazyObject(object): _wrapped = None def __init__(self): - self._wrapped = None + self._wrapped = empty __getattr__ = _new_method_proxy(getattr) @@ -946,14 +950,14 @@ class LazyObject(object): # Assign to __dict__ to avoid infinite __setattr__ loops. self.__dict__['_wrapped'] = value else: - if self._wrapped is None: + if self._wrapped is empty: self._setup() setattr(self._wrapped, name, value) def __delattr__(self, name): if name == '_wrapped': raise TypeError('can\'t delete _wrapped.') - if self._wrapped is None: + if self._wrapped is empty: self._setup() delattr(self._wrapped, name)