From 35e5ffaf854edd1ec8509427b7c94a1711ec0e07 Mon Sep 17 00:00:00 2001 From: Ray Walker Date: Thu, 16 Jun 2022 10:39:05 +1000 Subject: [PATCH] fix: Raise ValueError when check_names detects overlong names ValueError may not be the correct type? Closes #679 --- tools/check_names.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/check_names.py b/tools/check_names.py index 7e45fd877f..e3fcf88f16 100755 --- a/tools/check_names.py +++ b/tools/check_names.py @@ -84,13 +84,21 @@ def main(dirs, prefix_length=None): source_just = max(len(k) for k in MOD_LIMITS) name_just = max(len(n.name) for n in names) value_just = max(len(n.value) for n in names) + errors = [] for name in names: name_length = name.length + prefix_length - flag = '✗' if name_length >= MOD_LIMITS[name.source] else '✓' - print(f'[{flag}] {name.source.ljust(source_just)} ' - f'{name.name.ljust(name_just)} ' - f'{name.value.ljust(value_just)} ' - f'({name_length})') + if name_length >= MOD_LIMITS[name.source]: + flag = "✗" + errors += [f"{name.source}:{name.name}:{name_length}"] + else: + flag = "✓" + + print(f"[{flag}] {name.source.ljust(source_just)} " + f"{name.name.ljust(name_just)} " + f"{name.value.ljust(value_just)} " + f"({name_length})") + if errors: + raise ValueError(errors) if __name__ == '__main__':