lib: Fix silent assertitons

There are a couple of assert statements in the codebase which can make jw-pkg fail without any detail whatsoever if --backtrace is not specified, fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-25 07:45:14 +02:00
commit 3ac3aff997
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
7 changed files with 19 additions and 12 deletions

View file

@ -38,7 +38,8 @@ class FileContext(abc.ABC):
self.__in_pipe = in_pipe
self.__out_pipe = out_pipe
self.__open_count = 0
assert verbose_default is not None
if not verbose_default in [True, False]:
raise ValueError(f'Tried to instantiate FileContext with verbose_default = "{verbose_default}"')
async def __aenter__(self):
await self.open()
@ -87,7 +88,7 @@ class FileContext(abc.ABC):
if self.__open_count == 1:
await self._close()
self.__open_count -= 1
assert self.__open_count >= 0
assert self.__open_count >= 0, f'Closed file context "{self.__uri}" more often than opened'
@classmethod
def schema_from_uri(cls, uri: str) -> str: