Dashboard widgets: Rendered.moves is declared three times, and the lint rule that catches it is off #501

Closed
opened 2026-10-01 10:47:08 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, reading the dashboard widget code.

Checked again on 2026-10-01 against main at 0a5cad587: still present.

The Rendered dataclass declares the same field, with the same three-line comment, three times. It works only because the last declaration silently replaces the first two, so an edit to either of the first copies has no effect.

  • Where: core/widgets.py:395-406, class Rendered: moves: dict = field(default_factory=dict) at lines 398, 402 and 406, each under an identical #: comment.
  • What happens: a later change to the field's type or default made in the first or second copy is ignored without a warning; only the third copy counts.
  • Why it matters: a paste slip that hides edits. The project's ruff selection (pyproject.toml, [tool.ruff.lint] select) does not include flake8-pie, whose rule PIE794 (duplicate class field definition) reports exactly this: run in isolation over the file it finds the two extra copies.
  • Fix: keep one declaration and its comment; add "PIE794" (or "PIE") to the ruff select list so the next one is caught.

Done when

  • core/widgets.py declares moves once, and ruff check with PIE794 selected in pyproject.toml passes over src/.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, reading the dashboard widget code. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. The `Rendered` dataclass declares the same field, with the same three-line comment, three times. It works only because the last declaration silently replaces the first two, so an edit to either of the first copies has no effect. - **Where:** `core/widgets.py:395-406`, class `Rendered`: `moves: dict = field(default_factory=dict)` at lines 398, 402 and 406, each under an identical `#:` comment. - **What happens:** a later change to the field's type or default made in the first or second copy is ignored without a warning; only the third copy counts. - **Why it matters:** a paste slip that hides edits. The project's ruff selection (`pyproject.toml`, `[tool.ruff.lint] select`) does not include flake8-pie, whose rule `PIE794` (duplicate class field definition) reports exactly this: run in isolation over the file it finds the two extra copies. - **Fix:** keep one declaration and its comment; add `"PIE794"` (or `"PIE"`) to the ruff `select` list so the next one is caught. ## Done when - `core/widgets.py` declares `moves` once, and `ruff check` with `PIE794` selected in `pyproject.toml` passes over `src/`.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:47:08 +00:00
Sign in to join this conversation.
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
Postulo/postulo#501
No description provided.