fix(tui): use the is_running property for app guards that never fired (#894) - #939
Open
aniketshukla1 wants to merge 1 commit into
Open
fix(tui): use the is_running property for app guards that never fired (#894)#939aniketshukla1 wants to merge 1 commit into
aniketshukla1 wants to merge 1 commit into
Conversation
…usestrix#894) textual's App.is_mounted is a method taking a widget, not a property, so a bare self.is_mounted is an always-truthy bound method and every 'if not self.is_mounted: return' guard was dead. Worst case, the dead guard let query_one run against a missing screen, raise, get caught, and re-schedule via call_after_refresh — looping instead of returning. Switch the 13 app-level guards to App.is_running (the bool property these guards want). The one correct widget.is_mounted (a Widget property) is left unchanged. Resolves the mypy 'could always be true' / pyright reportUnnecessaryComparison findings in the issue.
Contributor
Greptile SummaryCorrects TUI lifecycle guards by checking whether the Textual app is running instead of treating the
Confidence Score: 5/5The PR appears safe to merge, with the corrected guards preventing TUI operations after the app stops running. The changes consistently replace always-truthy app method references with the intended boolean lifecycle property, and no reachable blocking or non-blocking defect remains. Important Files Changed
Reviews (1): Last reviewed commit: "fix(tui): use the is_running property fo..." | Re-trigger Greptile |
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.
Summary
textual'sApp.is_mountedis a method taking a widget, not a property — so a bareself.is_mountedis an always-truthy bound method, and everyif not self.is_mounted: returnguard in the TUI was dead. Worst case, the dead guard letquery_onerun against a missing screen, raise, get caught by the surroundingexcept, and re-schedule viacall_after_refresh— looping instead of returning.Closes #894.
Changes
Switch the 13 app-level guards in
strix/interface/tui/app.pytoApp.is_running(the bool property these guards actually want). The one correctwidget.is_mounted(aWidgetproperty) is left unchanged.This resolves the
mypy"Function 'is_mounted' could always be true in boolean context" andpyrightreportUnnecessaryComparisonfindings from the issue. Confirmed by introspection thatApp.is_runningis apropertyandApp.is_mountedis afunction, sonot self.is_runningis now a real check.