Skip to content
New issue

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

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

Already on GitHub? # to your account

Add main guard to examples (+ incredibly small fixes) #3181

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

damusss
Copy link
Member

@damusss damusss commented Oct 17, 2024

As @Starbuck5 pointed out on discord, many example lack the

if __name__ == "__main__":
	main()

guard and could run unexpectedly if auto-imported by some (not smart) IDE.

This PR fixes this.
You may also notice 2 or 3 very small unrelated fixes, I think they can pass too.
All examples still run, but you can run yourself aswell. I did the minimum refactoring possible.

NOTE: the diff github renders is kinda crazy, 99% of the time I just added one tab of indentation to the main functionality, I didn't actually change anything. You might want to compare them locally (or trust me).

@damusss damusss requested a review from a team as a code owner October 17, 2024 17:35
@bilhox
Copy link
Contributor

bilhox commented Oct 17, 2024

It might need a better name because it does not fix just that the PR.

@damusss damusss changed the title Add main guard to examples Add main guard to examples (+ incredibly small fixes) Oct 17, 2024
@bilhox bilhox added this to the 2.5.3 milestone Oct 17, 2024
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR 🎉

@ankith26 ankith26 merged commit 87aeb2d into pygame-community:main Oct 21, 2024
3 checks passed
@damusss damusss deleted the __main__-guard-examples branch December 1, 2024 10:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants