Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: spec_finder.py #89

Closed
wants to merge 10 commits into from
10 changes: 5 additions & 5 deletions spec_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_spec(force_refresh=False):
with open(SPEC_PATH, 'w', encoding='utf-8') as f:
f.write(data)
except Exception as e:
logging.error(f"Failed to fetch specification: {e}")
logging.error("Failed to fetch specification: %s", e)
sys.exit(1)

return json.loads(data)
Expand Down Expand Up @@ -71,7 +71,7 @@ def parse_rust_files() -> Dict[str, Dict[str, str]]:
text = _demarkdown(''.join(text_with_concat_chars) + '"')
repo_specs[number] = {'number': number, 'text': text}
except Exception as e:
logging.warning(f"Skipping {match} due to parsing error: {e}")
logging.warning("Skipping %s due to parsing error: %s", match, e)
return repo_specs

def main(refresh_spec: bool = False, diff_output: bool = False, limit_numbers: Optional[Set[str]] = None) -> None:
Expand All @@ -88,18 +88,18 @@ def main(refresh_spec: bool = False, diff_output: bool = False, limit_numbers: O
if number in spec_map:
txt = entry['text']
if txt != spec_map[number]:
logging.info(f"{number} is bad")
logging.info("%s is bad", number)
bad_num += 1
if diff_output:
diff = difflib.ndiff([txt], [spec_map[number]])
logging.info('\n'.join([li for li in diff if not li.startswith(' ')]))
else:
logging.info(f"{number} is defined in our tests, but couldn't find it in the spec")
logging.info("%s is defined in our tests, but couldn't find it in the spec", number)

if missing:
logging.info('In the spec, but not in our tests:')
for m in sorted(missing):
logging.info(f" {m}: {spec_map[m]}")
logging.info("%s: %s", m, spec_map[m])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that this lost it's preceeding whitespace, which my fuzzy memory tells me wsa to help with visual parsing of the output.


sys.exit(bad_num)

Expand Down