mypy: guard Optional Qt widgets/models (union-attr bucket) #18

Merged
clanker merged 1 commit from pr/mypy-none-guards into master 2026-08-14 20:08:03 +00:00
Member

mypy: guard Optional Qt widgets/models (union-attr bucket).

PyQt6 stubs return Optional for layout() / model() / header() / page() / document() / mimeData() / popup() etc. Each call site binds to a local with a None guard, or uses an already-owned reference:

  • panel — HeaderInsetTreeView header/vbar guards; Panel layout bound once; selectionModel() guard
  • search / tag — tree.model() → self.model; layout() guards
  • compose — cc/bcc row layout bound once; verticalScrollBar, document, _clear_layout guards
  • mainwindow — central layout bound once (also fixes addWidget(stretch=…)); reflow document() guard
  • editor — document() / mimeData() guards
  • address_completer — popup() / completionModel() guards
  • thread — header() / settings() / page() guards incl. scroll_message
  • controller — assert stdout is not None in SyncMailThread

Rebased after #17: 122 → 62 on this branch, zero new. Stacks on #17 (base updated).

**mypy: guard Optional Qt widgets/models (union-attr bucket).** PyQt6 stubs return `Optional` for `layout()` / `model()` / `header()` / `page()` / `document()` / `mimeData()` / `popup()` etc. Each call site binds to a local with a `None` guard, or uses an already-owned reference: - **panel** — HeaderInsetTreeView header/vbar guards; Panel layout bound once; `selectionModel()` guard - **search / tag** — `tree.model()` → `self.model`; `layout()` guards - **compose** — cc/bcc row layout bound once; `verticalScrollBar`, `document`, `_clear_layout` guards - **mainwindow** — central layout bound once (also fixes `addWidget(stretch=…)`); reflow `document()` guard - **editor** — `document()` / `mimeData()` guards - **address_completer** — `popup()` / `completionModel()` guards - **thread** — `header()` / `settings()` / `page()` guards incl. `scroll_message` - **controller** — `assert stdout is not None` in `SyncMailThread` Rebased after #17: **122 → 62** on this branch, zero new. Stacks on #17 (base updated).
PyQt6 stubs return Optional for layout()/model()/header()/page()/
document()/mimeData()/popup() etc. Bind each to a local with a None
guard, or use the already-owned model reference instead of
tree.model():

- panel: HeaderInsetTreeView header/vbar guards; Panel layout bound
  once (QVBoxLayout(self)); selectionModel guard
- search/tag: tree.model() -> self.model (equivalent, non-Optional);
  layout() guards
- compose: cc/bcc row layout bound once; verticalScrollBar, document,
  and _clear_layout guards
- mainwindow: central layout bound once (w_layout) — also fixes the
  addWidget(stretch=...) call-arg error; reflow document guard
- editor: document()/mimeData() guards in body_text, drop, drag
- address_completer: popup()/completionModel() guards
- thread: header()/settings()/page() guards, incl. scroll_message
- controller: assert stdout is not None in SyncMailThread

mypy: 122 -> 62, zero new.
clanker force-pushed pr/mypy-none-guards from 0eded1ea79 to 220708c885 2026-08-14 20:02:58 +00:00 Compare
clanker changed target branch from pr/mypy-event-signatures to master 2026-08-14 20:04:22 +00:00
clanker force-pushed pr/mypy-none-guards from 220708c885 to aa7351a15f 2026-08-14 20:04:36 +00:00 Compare
clanker merged commit b8a1ed5078 into master 2026-08-14 20:08:03 +00:00
clanker deleted branch pr/mypy-none-guards 2026-08-14 20:08:04 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Home/lazarus!18
No description provided.