diff --git a/HISTORY.rst b/HISTORY.rst index 5f074ef9d..c3424cced 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +0.1.36 +++++++ +* Remove colorama reference (#321) + 0.1.35 ++++++ * Support Python 3.10 (#319) diff --git a/azdev/__init__.py b/azdev/__init__.py index 62c39b9f1..a4bdba154 100644 --- a/azdev/__init__.py +++ b/azdev/__init__.py @@ -4,4 +4,4 @@ # license information. # ----------------------------------------------------------------------------- -__VERSION__ = '0.1.35' +__VERSION__ = '0.1.36' diff --git a/azdev/operations/linter/linter.py b/azdev/operations/linter/linter.py index 29f9354e2..e5f8fee9d 100644 --- a/azdev/operations/linter/linter.py +++ b/azdev/operations/linter/linter.py @@ -10,7 +10,6 @@ from pkgutil import iter_modules from enum import Enum import yaml -import colorama from knack.log import get_logger from azdev.utilities.path import get_cli_repo_path, get_ext_repo_paths @@ -255,7 +254,6 @@ def run(self, run_params=None, run_commands=None, run_command_groups=None, run_h found_rules.add(rule_name) add_to_linter_func(self) - colorama.init() # run all rule-checks if run_help_files_entries and self._rules.get('help_file_entries'): self._run_rules('help_file_entries') @@ -290,11 +288,15 @@ def run(self, run_params=None, run_commands=None, run_command_groups=None, run_h with open(exclusion_path, 'w') as f: yaml.safe_dump(exclusions, f) - colorama.deinit() return self.exit_code def _run_rules(self, rule_group): - from colorama import Fore + # https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formatting + RED = '\x1b[31m' + GREEN = '\x1b[32m' + YELLOW = '\x1b[33m' + CYAN = '\x1b[36m' + RESET = '\x1b[39m' for rule_name, (rule_func, linter_callable, rule_severity) in self._rules.get(rule_group).items(): severity_str = rule_severity.name # use new linter if needed @@ -304,20 +306,21 @@ def _run_rules(self, rule_group): violations = sorted(rule_func()) or [] if violations: if rule_severity == LinterSeverity.HIGH: - sev_color = Fore.RED + sev_color = RED elif rule_severity == LinterSeverity.MEDIUM: - sev_color = Fore.YELLOW + sev_color = YELLOW else: - sev_color = Fore.CYAN + sev_color = CYAN - print('- {} FAIL{} - {}{}{} severity: {}'.format(Fore.RED, Fore.RESET, sev_color, - severity_str, Fore.RESET, rule_name,)) + # pylint: disable=duplicate-string-formatting-argument + print('- {} FAIL{} - {}{}{} severity: {}'.format(RED, RESET, sev_color, + severity_str, RESET, rule_name,)) for violation_msg, entity_name, name in violations: print(violation_msg) self._save_violations(entity_name, name) print() else: - print('- {} pass{}: {} '.format(Fore.GREEN, Fore.RESET, rule_name)) + print('- {} pass{}: {} '.format(GREEN, RESET, rule_name)) def _linter_severity_is_applicable(self, rule_severity, rule_name): if self.min_severity.value > rule_severity.value: