diff --git a/pylib/anki/rsbackend.py b/pylib/anki/rsbackend.py index 179280699..e5c631875 100644 --- a/pylib/anki/rsbackend.py +++ b/pylib/anki/rsbackend.py @@ -32,7 +32,6 @@ from anki.dbproxy import Row as DBRow from anki.dbproxy import ValueForDB from anki.fluent_pb2 import FluentString as TR from anki.rsbackend_gen import RustBackendGenerated -from anki.types import assert_impossible_literal if TYPE_CHECKING: from anki.fluent_pb2 import FluentStringValue as TRValue diff --git a/pylib/anki/types.py b/pylib/anki/types.py index 28445aebf..1783afc67 100644 --- a/pylib/anki/types.py +++ b/pylib/anki/types.py @@ -1,16 +1,5 @@ -import enum -from typing import Any, NoReturn +from typing import NoReturn -class _Impossible(enum.Enum): - pass - - -def assert_impossible(arg: NoReturn) -> NoReturn: - raise Exception(f"unexpected arg received: {type(arg)} {arg}") - - -# mypy is not yet smart enough to do exhaustiveness checking on literal types, -# so this will fail at runtime instead of typecheck time :-( -def assert_impossible_literal(arg: Any) -> NoReturn: +def assert_exhaustive(arg: NoReturn) -> NoReturn: raise Exception(f"unexpected arg received: {type(arg)} {arg}") diff --git a/qt/aqt/mediasync.py b/qt/aqt/mediasync.py index fa7ce3bd7..74294b184 100644 --- a/qt/aqt/mediasync.py +++ b/qt/aqt/mediasync.py @@ -16,7 +16,7 @@ from anki.rsbackend import ( NetworkError, ProgressKind, ) -from anki.types import assert_impossible +from anki.types import assert_exhaustive from anki.utils import intTime from aqt import gui_hooks from aqt.qt import QDialog, QDialogButtonBox, QPushButton, QTextCursor, QTimer, qconnect @@ -206,7 +206,7 @@ class MediaSyncDialog(QDialog): elif isinstance(entry.entry, MediaSyncProgress): txt = self._logentry_to_text(entry.entry) else: - assert_impossible(entry.entry) + assert_exhaustive(entry.entry) return self._time_and_text(entry.time, txt) def _logentry_to_text(self, e: MediaSyncProgress) -> str: