diff options
author | Tamas Szabo <szabtam@gmail.com> | 2020-08-26 14:20:18 +0300 |
---|---|---|
committer | Tamas Szabo <szabtam@gmail.com> | 2020-08-26 14:20:18 +0300 |
commit | 904324db7cffa2582185acce64020419c210ef71 (patch) | |
tree | 58c122fc45e3a6d16e85872591e2982d3b22276a | |
parent | 29daaf9476b11e2978477362e23959aaf863edab (diff) | |
download | isort-issue/1412/missing-colorama-exception.tar.gz |
Bugfix: 1412 Missing colorama leads to exceptionissue/1412/missing-colorama-exception
Fixes #1412.
-rw-r--r-- | isort/format.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/isort/format.py b/isort/format.py index 67c8c5b1..fbe122d5 100644 --- a/isort/format.py +++ b/isort/format.py @@ -114,13 +114,14 @@ class BasicPrinter: class ColoramaPrinter(BasicPrinter): - ADDED_LINE = colorama.Fore.GREEN - REMOVED_LINE = colorama.Fore.RED - def __init__(self, output: Optional[TextIO] = None): self.output = output or sys.stdout + # Note: this constants are instance variables instead ofs class variables + # because they refer to colorama which might not be installed. self.ERROR = self.style_text("ERROR", colorama.Fore.RED) self.SUCCESS = self.style_text("SUCCESS", colorama.Fore.GREEN) + self.ADDED_LINE = colorama.Fore.GREEN + self.REMOVED_LINE = colorama.Fore.RED @staticmethod def style_text(text: str, style: Optional[str] = None) -> str: |