diff options
-rw-r--r-- | gitsrht/editorconfig.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gitsrht/editorconfig.py b/gitsrht/editorconfig.py index b6f2257..9391657 100644 --- a/gitsrht/editorconfig.py +++ b/gitsrht/editorconfig.py @@ -46,18 +46,19 @@ class EditorConfig: def tab_width(self): if self._config == None: return 8 - val = self._config.get("tab_size", self._config.get("indent_size", 8)) - if not isinstance(val, int): + try: + return int(self._config.get("tab_size", + self._config.get("indent_size", 8))) + except ValueError: return 8 - return val def max_line_length(self): if self._config == None: return 80 - val = self._config.get("max_line_length", 80) - if not isinstance(val, int): + try: + return int(self._config.get("max_line_length", 80)) + except ValueError: return 80 - return val # Via https://github.com/editorconfig/editorconfig-core-py/blob/master/editorconfig/fnmatch.py # 2-Clause BSD |