Unverified Commit b0b1703f authored by karp's avatar karp
Browse files

Fix LSP error in UtcDateTime#process_bind_param

According to mypy the previous annotation violated the LSP.
We now use the types of the supertype method and return a
datetime object only if the argument was a datetime-object.
parent aa6c5152
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -28,13 +28,13 @@ class UtcDateTime(types.TypeDecorator):
        return types.String(32)

    def process_bind_param(
        self, value: datetime, dialect: Dialect
        self, value: Any | None, dialect: Dialect
    ) -> Optional[str | datetime]:
        if value is None:
            return None

        if isinstance(value, datetime):
            return value.astimezone(timezone.utc).isoformat()

        return None

    def process_result_value(
        self, value: str | datetime, dialect: Dialect
    ) -> Optional[datetime]: