Skip to content

Commit

Permalink
Merge pull request #680 from 27Bslash6/fix--raise-an-error-in-check_n…
Browse files Browse the repository at this point in the history
…ames.py-if-lengths-exceeded

fix: Raise ValueError when check_names detects overlong names
  • Loading branch information
juliocc authored Jun 16, 2022
2 parents 6c63c6a + 35e5ffa commit 704592b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tools/check_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit 704592b

Please sign in to comment.