Skip to content
Snippets Groups Projects

Make MyPy happy

Merged karp requested to merge make-mypy-happy into master
All threads resolved!
1 file
+ 2
2
Compare changes
  • Side-by-side
  • Inline
  • aa6c5152
    Fix type annotation of UUID · aa6c5152
    karp authored
    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.
+ 2
2
@@ -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
Loading