Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
1 merge request!22Make MyPy happy
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment