import-scripts: fix IndexError for options with no declarations (#330)

This commit is contained in:
Naïm Favier 2021-08-02 22:30:46 +02:00 committed by GitHub
parent 25b085fb41
commit 42b0e87393
Failed to generate hash of commit

View file

@ -552,6 +552,9 @@ def get_options(evaluation):
option_name_query = parse_query(name) option_name_query = parse_query(name)
declarations = option.get("declarations", [])
option_source = declarations[0] if declarations else None
yield dict( yield dict(
type="option", type="option",
option_name=name, option_name=name,
@ -563,7 +566,7 @@ def get_options(evaluation):
option_type=option.get("type"), option_type=option.get("type"),
option_default=default, option_default=default,
option_example=example, option_example=example,
option_source=option.get("declarations", [None])[0], option_source=option_source,
) )
return len(options), gen return len(options), gen