Skip to content

Guard the layout item in clear_layout - #142

Merged
miciav merged 1 commit into
mainfrom
fix/guard-layout-takeat-none
Sep 11, 2026
Merged

miciav merged 1 commit into
mainfrom
fix/guard-layout-takeat-none

Conversation

@miciav

@miciav miciav commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Surfaced by dependabot #140 (pyside6 6.10.1 → 6.11.2), which is currently blocked on it.

The failure

lb_gui/utils/qt.py:19:23 - error: "widget" is not a known attribute of "None"
  (reportOptionalMemberAccess)
item = layout.takeAt(0)
widget = item.widget()      # item may be None

PySide6 types QLayout.takeAt as returning QLayoutItem up to 6.10 and QLayoutItem | None from 6.11, where an out-of-range index yields null. I checked both sides: the installed 6.10.1 stub declares takeAt(...) -> QLayoutItem and main is 0/0/0, while the error appears only on the 6.11.2 branch.

This is only visible now because #139 put lb_gui under basedpyright for the first time — the line itself predates the migration and mypy never saw it.

Scope

The while layout.count() condition makes the None case unreachable in practice, so this is a latent robustness issue rather than an observed crash. It is the only takeAt call site in the tree, and the CI run on #140 reports exactly one error, so this single guard is the whole blocker.

Verification

  • basedpyright clean under the installed PySide6 6.10.1 (0 errors, 0 warnings)
  • The same narrowing accepted under a stub that returns Item | None, confirming it satisfies reportOptionalMemberAccess in standard mode
  • lb_gui tests pass; ruff and formatting clean; all pre-commit hooks pass

The definitive check is #140 rebasing onto this and going green.

🤖 Generated with Claude Code

PySide6 types QLayout.takeAt as returning QLayoutItem up to 6.10 and
QLayoutItem | None from 6.11, where an out-of-range index yields null. The bump
to 6.11.2 in dependabot PR #140 therefore turns

    item = layout.takeAt(0)
    widget = item.widget()

into reportOptionalMemberAccess, because that member access lands on a
possibly-None item.

This only surfaces now because #139 put lb_gui under basedpyright for the first
time; the line itself predates the migration. The while loop makes the None case
unreachable in practice, so it is a latent robustness issue rather than an
observed crash, but the guard is what makes the call correct under either
typing. This is the only takeAt call site in the tree.

Verified: basedpyright clean under the installed PySide6 6.10.1, the same
narrowing accepted under an Optional-returning stub, lb_gui tests pass, ruff and
format clean. The definitive check is #140 rebasing onto this and going green.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-11T15:05:29.761564Z edfad40 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@miciav
miciav merged commit 52e6388 into main Sep 11, 2026
4 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.

1 participant