Repository: datafolklabs/cement

Issue:
Configparser 'getboolean' exception
**System Information**

- Cement Version: 3.0.0
- Python Version: 3.6.8
- Operating System and Version: Linux Mint 19.1

**Steps to Reproduce (Bugs Only)**

- Create a boolean setting: configparser only supports string values so this has to be a string representation of a boolean. [According to configparser](https://docs.python.org/3/library/configparser.html#supported-datatypes), this includes 

  > 'yes'/'no', 'on'/'off', 'true'/'false' and '1'/'0'

- Access this value using the `getboolean` method recommended by configparser. This should automatically convert the string value to a bool. Example usage:
`if self.app.config['hydra'].getboolean('validator_metrics'):`
- Exception:
  ```Traceback (most recent call last):
  File "/home/adam/.pyenv/versions/hydra/bin/hydra", line 11, in <module>
    load_entry_point('hydra', 'console_scripts', 'hydra')()
  File "/home/adam/PycharmProjects/hydra/hydra/main.py", line 152, in main
    app.run()
  File "/home/adam/.pyenv/versions/hydra/lib/python3.6/site-packages/cement-3.0.0-py3.6.egg/cement/core/foundation.py", line 916, in run
    return_val = self.controller._dispatch()
  File "/home/adam/.pyenv/versions/hydra/lib/python3.6/site-packages/cement-3.0.0-py3.6.egg/cement/ext/ext_argparse.py", line 806, in _dispatch
    return func()
  File "/home/adam/PycharmProjects/hydra/hydra/controllers/client.py", line 621, in enable_metrics
    self.app.client.configure_metrics()
  File "/home/adam/PycharmProjects/hydra/hydra/helpers/client.py", line 275, in configure_metrics
    if self.app.config['hydra'].getboolean('validator_metrics'):
  File "/home/adam/.pyenv/versions/3.6.8/lib/python3.6/configparser.py", line 1283, in get
    fallback=fallback, **kwargs)
  File "/home/adam/.pyenv/versions/3.6.8/lib/python3.6/configparser.py", line 829, in getboolean
    raw=raw, vars=vars, fallback=fallback, **kwargs)
  File "/home/adam/.pyenv/versions/3.6.8/lib/python3.6/configparser.py", line 809, in _get_conv
    **kwargs)
  File "/home/adam/.pyenv/versions/3.6.8/lib/python3.6/configparser.py", line 803, in _get
    return conv(self.get(section, option, **kwargs))
  TypeError: get() got an unexpected keyword argument 'raw'
  ```

I am thinking this is due to the fact that cement does not pass kwargs to configparser's wrapped `get` method. I am going to attempt making a PR to address this issue.


Comments:

Patch:
diff --git a/cement/ext/ext_configparser.py b/cement/ext/ext_configparser.py
index 587e89e..0aa8f0d 100644
--- a/cement/ext/ext_configparser.py
+++ b/cement/ext/ext_configparser.py
@@ -152,12 +152,12 @@ class ConfigParserConfigHandler(config.ConfigHandler, RawConfigParser):
         env_var = re.sub('[^0-9a-zA-Z]+', '_', env_var)
         return env_var
 
-    def get(self, section, key):
+    def get(self, section, key, **kwargs):
         env_var = self._get_env_var(section, key)
         if env_var in os.environ.keys():
             return os.environ[env_var]
         else:
-            return RawConfigParser.get(self, section, key)
+            return RawConfigParser.get(self, section, key, **kwargs)
 
     def has_section(self, section):
         return RawConfigParser.has_section(self, section)


Test patch:
diff --git a/tests/ext/test_ext_configparser.py b/tests/ext/test_ext_configparser.py
index b0ed755..e5bf5fa 100644
--- a/tests/ext/test_ext_configparser.py
+++ b/tests/ext/test_ext_configparser.py
@@ -54,3 +54,15 @@ def test_env_var_override():
         assert app.config.get('dummy', 'foo') == 'dummy-not-bar'
         section_dict = app.config.get_section_dict('dummy')
         assert section_dict['foo'] == 'dummy-not-bar'
+
+
+def test_get_boolean():
+    with TestApp(config_section='testapp') as app:
+        app.config.set('testapp', 'foobool', 'true')
+        assert app.config['testapp'].getboolean('foobool') is True
+
+        app.config.set('testapp', 'foobool', 'no')
+        assert app.config['testapp'].getboolean('foobool') is False
+
+        os.environ['TESTAPP_FOOBOOL'] = '1'
+        assert app.config['testapp'].getboolean('foobool') is True