Skip to content

Commit

Permalink
fix: Raise ValueError when check_names detects overlong names
Browse files Browse the repository at this point in the history
ValueError may not be the correct type?

Closes #679
  • Loading branch information
Ray Walker committed Jun 16, 2022
1 parent 6c63c6a commit 35e5ffa
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 35e5ffa

Please sign in to comment.