clean: add if __name__ == "__main__" in prepare_readme.py tto avoid modifications to README-PYPI.md when collecting tests#559
Merged
Conversation
andreaonofrei01
approved these changes
Jun 1, 2026
Contributor
andreaonofrei01
left a comment
There was a problem hiding this comment.
nice catch, lgtm
…odifications to README-PYPI.md when collecting tests
73278db to
7ff2086
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
README-PYPI.mdkept showing up as an unstaged change in local working trees even when no one touched the repo.Root cause:
scripts/prepare_readme.pyhas noif __name__ == "__main__":guard, so its top-level body — which writesREADME-PYPI.mdfromREADME.md— runs at import time.tests/test_prepare_readme.pyimports the script viaspec.loader.exec_module(...), and VS Code's Python extension auto-runspytest --collect-onlyon workspace open and on save, silently regeneratingREADME-PYPI.mdeach time.Change
Wrap the side-effecting code in
main()behind the standard__main__guard. Direct invocation (python scripts/prepare_readme.py, used byscripts/publish.shand the publish workflow) is unchanged; importing it is now a no-op.