Fix typecheck errors in prefix disambiguation

This commit is contained in:
Jared Miller 2026-02-08 13:50:26 -05:00
parent 8c83130f67
commit 37766ad69f
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
2 changed files with 6 additions and 3 deletions

View file

@ -3,6 +3,7 @@
import logging import logging
from collections.abc import Awaitable, Callable from collections.abc import Awaitable, Callable
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import cast
from mudlib.player import Player from mudlib.player import Player
@ -130,7 +131,8 @@ async def dispatch(player: Player, raw_input: str) -> None:
if len(names) == 2: if len(names) == 2:
msg = f"{names[0]} or {names[1]}?\r\n" msg = f"{names[0]} or {names[1]}?\r\n"
else: else:
msg = f"{', '.join(names[:-1])}, or {names[-1]}?\r\n" prefix = ", ".join(cast(list[str], names[:-1]))
msg = f"{prefix}, or {names[-1]}?\r\n"
player.writer.write(msg) player.writer.write(msg)
await player.writer.drain() await player.writer.drain()
return return

View file

@ -1,6 +1,6 @@
"""Help and command listing commands.""" """Help and command listing commands."""
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, cast
from mudlib.commands import CommandDefinition, _registry, register, resolve_prefix from mudlib.commands import CommandDefinition, _registry, register, resolve_prefix
from mudlib.commands.movement import DIRECTIONS from mudlib.commands.movement import DIRECTIONS
@ -28,7 +28,8 @@ async def _show_command_detail(player: Player, command_name: str) -> None:
if len(names) == 2: if len(names) == 2:
msg = f"{names[0]} or {names[1]}?\r\n" msg = f"{names[0]} or {names[1]}?\r\n"
else: else:
msg = f"{', '.join(names[:-1])}, or {names[-1]}?\r\n" prefix = ", ".join(cast(list[str], names[:-1]))
msg = f"{prefix}, or {names[-1]}?\r\n"
await player.send(msg) await player.send(msg)
return return
else: else: