diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-02-11 11:36:22 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-02-11 11:36:22 -0500 |
commit | 09607c8917d4b10366527bbb2a2040c027593cde (patch) | |
tree | 1d7d02ba900672f67a61eb394f1ebf3a3dcb24d0 | |
parent | 3b66235f6d5952cf28bac812cb744b33d0d4cd58 (diff) |
Cast editorconfig values to int
-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 |