Skip to content

Resolve all mypy typing errors and enable full-project type checking #18

Description

@dasarne

Background

The CI pipeline currently limits mypy checks to the stable core modules because the Qt UI layer still contains a large number of typing issues.

Current status:

  • Tests pass on Python 3.10–3.12
  • Qt headless CI works correctly
  • Core modules are type-checked
  • Full-project mypy currently reports ~116 errors

Affected areas include:

  • src/ui/editor_panel.py
  • src/ui/canvas_panel.py
  • src/ui/main_window.py
  • src/ui/widgets.py
  • src/ui/comment_panel.py
  • src/ui/settings_dialog.py
  • src/ui/warnings_dialog.py

Main Error Categories

Qt override signatures

Examples:

  • paintEvent(self, event)
  • resizeEvent(self, event)
  • mousePressEvent(self, event)

PyQt6 stubs require signatures like:

  • QPaintEvent | None
  • QResizeEvent | None
  • QMouseEvent | None

Optional Qt return values

Examples:

  • menuBar()
  • statusBar()
  • document()
  • clipboard()
  • horizontalHeader()

These are currently treated as always available but typed as optional in PyQt6 stubs.

Painter overload typing

Examples:

  • QPainter.drawLines(list[QLineF])

PyQt6 expects array-compatible overloads.

Goals

  • Eliminate all current mypy errors
  • Re-enable full-project mypy checking in CI
  • Improve maintainability and IDE support
  • Prepare the UI layer for stricter future typing

Requirements

  • No functional regressions
  • No UX regressions
  • Preserve editor responsiveness
  • Preserve rendering performance
  • Avoid broad type: ignore usage
  • Prefer explicit typing and safe Optional handling
  • Keep changes incremental and reviewable

Suggested Migration Order

  1. Fix override signatures
  2. Fix Optional Qt object handling
  3. Fix painter/container overload typing
  4. Add missing annotations
  5. Re-enable full mypy src/ in CI

Acceptance Criteria

  • mypy src/ passes without errors
  • CI fully green on all Python versions
  • No runtime regressions
  • No unnecessary suppression comments
  • Typing quality improved across UI modules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions