class DbInfiniteInt(TypeDecorator): # type: ignore
"""
A codec which maps a database integer value to "MaybeInfiniteInt"
"""
impl = Integer
def process_bind_param(
self,
value: Optional[MaybeInfiniteInt],
dialect: Dialect,
) -> Optional[int]: # <-- mypy complains about this return-type
if value is None:
return None
if value.is_infinite():
return -1
return int(value)