Skip to content

Commit

Permalink
improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mzuenni committed Apr 10, 2024
1 parent b703e34 commit ed52a12
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,17 @@ def _read_settings(self):
fatal(f'could not parse constants in {self.name}/problem.yaml')
raw_constants = self.settings.constants
self.settings.constants = {
k: v for k, v in raw_constants.items() if isinstance(v, (str, int, float))
k: v
for k, v in raw_constants.items()
if isinstance(v, (str, int, float))
and config.SUBSTITUTE_NAME_REGEX.fullmatch(k) is not None
}
for k in raw_constants:
if k not in self.settings.constants:
error(f'invalid value for constant {k} in {self.name}/problem.yaml (ignored)')
if config.SUBSTITUTE_NAME_REGEX.fullmatch(key) is None:
error(f'invalid name "{k}" for constant in {self.name}/problem.yaml (ignored)')
else:
error(f'invalid value for constant {k} in {self.name}/problem.yaml (ignored)')

# reserved constants (and backwards compatibility)
known_constants = {
Expand Down

0 comments on commit ed52a12

Please sign in to comment.