You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
408 B
Python

from typing import (
Literal,
)
def update_bool_value(
old_value: bool,
new_value: bool | Literal["toggle"],
) -> bool:
if new_value == "toggle":
return not old_value
if type(new_value) != bool:
raise Exception(
f'Invalid type of new_value: Expected bool or literal "toggle", got type={type(new_value)!r}, value={new_value!r}'
)
return new_value