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

Fix type annotation of UUID

According to mypy the previous annotation violated the LSP.
Therefore, we use the types of the supertype method and check for
correct types in the method.
parent 9df2b5d6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -26,12 +26,12 @@ class Uuid(types.TypeDecorator):
    def load_dialect_impl(self, dialect: Dialect) -> types.TypeEngine[Any]:
        return types.String(UUID_LENGTH)

    def process_bind_param(self, value: str | UUID, dialect: Dialect) -> Optional[str]:
    def process_bind_param(self, value: Any | None, dialect: Dialect) -> Optional[str]:
        if isinstance(value, str):
            # Manually create UUID from string, to raise an error if the string is malformed
            UUID(value)

        return str(value) if value else None
        return str(value) if isinstance(value, UUID) else None

    def process_result_value(
        self, value: Optional[str], dialect: Dialect