Skip to content

Ensure project bootstraps generate ruff-clean code. - #3144

Merged
mhsmith merged 3 commits into
beeware:mainfrom
freakboy3742:bootstrap-cleanup
Nov 11, 2026
Merged

mhsmith merged 3 commits into
beeware:mainfrom
freakboy3742:bootstrap-cleanup

Conversation

@freakboy3742

@freakboy3742 freakboy3742 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Clean up some unused imports and variables to ensure that generated projects pass a default Ruff configuration.

  • The ROW and COLUMN imports were unused in the default Toga configuration (but can be easily added when needed)
  • The main_window object was never used in the PySide6 configuration.

Refs beeware/.github#380.

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Comment thread src/briefcase/bootstraps/pyside6.py Outdated

app = QtWidgets.QApplication(sys.argv)
main_window = {{ cookiecutter.class_name }}()
_ = {{ cookiecutter.class_name }}()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it necessary to assign this to a variable to keep it in existence? Doesn't showing the window automatically add a reference from the app?

If it is necessary, I think a normal variable name and a noqa comment with an explanation would be better than relying on _ for something so important.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It has to be assigned to something - otherwise the object passes out of scope and is garbage collected, so the window is never displayed.

I'd rather avoid a noqa in freshly generated template code; I've found another solution - factor the show() out of init_ui so that main_window is used. It's arguably a better idea to keep displaying the window indpendent of construction anyway, so we can kill 2 birds with 1 stone.

@freakboy3742
freakboy3742 requested a review from mhsmith November 10, 2026 21:49
@mhsmith
mhsmith merged commit f9fc4cb into beeware:main Nov 11, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants