Skip to content

Commit e423caa

Browse files
committed
fix(explorer): satisfy the mypy gate on the explorer surface [roadmap:v0.8.9]
Annotates the parameters mypy flagged (schema reference, palette row, editor launcher widget, lookup state) and corrects the view-history annotation to the (view, path) tuples it has stored since v0.8.7. No behaviour change; CI lint gate is the driver.
1 parent 8c17936 commit e423caa

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/rac/explorer/adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from rac.core.frontmatter import split_frontmatter
1616
from rac.core.fs import find_markdown_files
1717
from rac.core.operations import CancelToken, OperationCancelled, Progress
18-
from rac.core.schema import available_schemas, schema_reference
18+
from rac.core.schema import SchemaReference, available_schemas, schema_reference
1919
from rac.services.improve import improve_file
2020
from rac.services.ingest import ConversionError, UnsupportedDocument, ingest
2121
from rac.services.repository import Artifact, Repository, load_repository
@@ -479,7 +479,7 @@ def schema_detail(self, name: str) -> str | None:
479479
return "\n".join(lines)
480480

481481
@staticmethod
482-
def _schema_section(ref, section: str) -> str:
482+
def _schema_section(ref: SchemaReference, section: str) -> str:
483483
description = ref.descriptions.get(section)
484484
values = ref.metadata.get(section)
485485
line = f" {section.title()}"

src/rac/explorer/screens/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323

2424
from rac.explorer import commands, mascot
2525
from rac.explorer.adapter import ExplorerAdapter
26-
from rac.explorer.state import LoadErrorState, LoadProgressState, RepositorySummaryState
26+
from rac.explorer.state import (
27+
LoadErrorState,
28+
LoadProgressState,
29+
LookupState,
30+
RepositorySummaryState,
31+
)
2732
from rac.explorer.widgets.appbar import AppBar
2833
from rac.explorer.widgets.palette import CommandPalette
2934
from rac.explorer.widgets.sidebar import NavigationSidebar
@@ -86,7 +91,7 @@ class MainScreen(Screen[None]):
8691
def __init__(self, adapter: ExplorerAdapter) -> None:
8792
super().__init__()
8893
self.adapter = adapter
89-
self._history: list[str] = []
94+
self._history: list[tuple[str, str | None]] = []
9095
self._last_focus: Widget | None = None
9196
# Live reload (v0.8.9): the corpus snapshot the last load saw. None
9297
# means "do not watch" — before the first successful load, after a
@@ -461,7 +466,7 @@ def _show_examples(self) -> None:
461466
options.extend(Option(f" {example}", disabled=True) for example in commands.EXAMPLES)
462467
self._show_results(options)
463468

464-
def _show_lookup(self, lookup) -> None:
469+
def _show_lookup(self, lookup: LookupState) -> None:
465470
if lookup.rows:
466471
# Artifact rows render through the filterable path (v0.8.9).
467472
self.query_one(ResultsView).show_lookup(lookup.rows, lookup.message)

src/rac/explorer/widgets/palette.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from rac.explorer import commands
2222
from rac.explorer.adapter import ExplorerAdapter
23+
from rac.explorer.state import ArtifactRow
2324
from rac.explorer.widgets.sidebar import type_tag
2425

2526
# Quick-open shows at most this many artifact matches; full result sets
@@ -38,7 +39,7 @@ def _command_option(spec: commands.CommandSpec) -> Option:
3839
return Option(label, id=f"cmd:{spec.name}")
3940

4041

41-
def _artifact_option(row) -> Option:
42+
def _artifact_option(row: ArtifactRow) -> Option:
4243
tag, colour = type_tag(row.type)
4344
label = Text()
4445
label.append(tag, style=f"bold {colour}")

src/rac/explorer/widgets/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from textual.binding import Binding
1717
from textual.containers import Vertical, VerticalScroll
1818
from textual.message import Message
19+
from textual.widget import Widget
1920
from textual.widgets import Input, Markdown, OptionList, Static, TabbedContent, TabPane, Tabs
2021
from textual.widgets.option_list import Option
2122
from textual.worker import Worker, WorkerState, get_current_worker
@@ -66,7 +67,7 @@ def __init__(self, key: str) -> None:
6667
self.key = key
6768

6869

69-
def launch_editor(widget, adapter: ExplorerAdapter, path: str) -> editor_mod.EditorOutcome:
70+
def launch_editor(widget: Widget, adapter: ExplorerAdapter, path: str) -> editor_mod.EditorOutcome:
7071
"""Open ``path`` in the configured editor from any widget (ADR-024).
7172
7273
Terminal editors run with the application suspended and resumed;

0 commit comments

Comments
 (0)