Skip to content

Commit

Permalink
fix/remove_broken_patch (#107)
Browse files Browse the repository at this point in the history
* fix/remove_broken_patch

patch for mycroft-era `Configuration.get`  (now `Configuration()`) is broken and causes .get to behave weirdly

```
  self.config = dict(Configuration()) # below is False, like in mycroft.conf
        self.config = Configuration() # below is None ????
        self.audio_enabled = self.config.get("enable_old_audioservice")
```

* bad test

* signal breaking change

ripping out a broken patch that we dont use anywhere, but technically a breaking change. 

who knows how many places are not actually reading config...

bumping to 0.1.0 in case anything depends on the broken behaviour

* Update version.py
  • Loading branch information
JarbasAl authored Feb 7, 2024
1 parent 35e83db commit f21d074
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
15 changes: 0 additions & 15 deletions ovos_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ class Configuration(dict):
_callbacks = []

def __init__(self):
# python does not support proper overloading
# when instantiation a Configuration object (new style)
# the get method is replaced for proper dict behaviour
self.get = self._real_get
super().__init__(**self.load_all_configs())

# dict methods
Expand Down Expand Up @@ -378,17 +374,6 @@ def patch_clear(message):
Configuration.__patch = {}

# Backwards compat methods
@staticmethod
def get(configs=None, cache=True, remote=True):
"""DEPRECATED - use Configuration class instead"""
LOG.warning("Configuration.get() has been deprecated, use Configuration() instead")
# NOTE: this is only called if using the class directly
# if using an instance (dict object) self._real_get is called instead
return Configuration.load_config_stack(configs, cache, remote)

def _real_get(self, key, default=None):
return self.__getitem__(key) or default

@staticmethod
def clear_cache(message=None):
"""DEPRECATED - there is no cache anymore """
Expand Down
9 changes: 0 additions & 9 deletions test/unittests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ def tearDown(self):
Configuration.load_config_stack([{}], True)
Configuration._callbacks = []

def test_get(self):
from ovos_config.config import Configuration
d1 = {'a': 1, 'b': {'c': 1, 'd': 2}}
d2 = {'b': {'d': 'changed'}}
d = Configuration.get([d1, d2])
self.assertEqual(d['a'], d1['a'])
self.assertEqual(d['b']['d'], d2['b']['d'])
self.assertEqual(d['b']['c'], d1['b']['c'])

@patch('mycroft.api.DeviceApi')
@skip("requires backend to be enabled, TODO refactor test!")
def test_remote(self, mock_api):
Expand Down

0 comments on commit f21d074

Please sign in to comment.