Skip to content

Commit

Permalink
check_newsfragments: Improve output on Windows machines (#7612)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Sassoulas <[email protected]>
  • Loading branch information
DudeNr33 and Pierre-Sassoulas authored Oct 30, 2022
1 parent dfd0e5a commit 5c7f980
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions script/check_newsfragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def check_file(file: Path, verbose: bool) -> bool:
if match:
issue = match.group("issue")
if file.stem != issue:
print(
echo(
f"{file} must be named '{issue}.<fragmenttype>', after the issue it references."
)
return False
if verbose:
print(f"Checked '{file}': LGTM πŸ€–πŸ‘")
echo(f"Checked '{file}': LGTM πŸ€–πŸ‘")
return True
print(
echo(
f"""\
{file}: does not respect the standard format πŸ€–πŸ‘Ž
Expand All @@ -82,5 +82,11 @@ def check_file(file: Path, verbose: bool) -> bool:
return False


def echo(msg: str) -> None:
# To support non-UTF-8 environments like Windows, we need
# to explicitly encode the message instead of using plain print()
sys.stdout.buffer.write(f"{msg}\n".encode())


if __name__ == "__main__":
sys.exit(main())

0 comments on commit 5c7f980

Please sign in to comment.