sqlalchemy-stubs
sqlalchemy-stubs copied to clipboard
Infer non-optional types for some type decorators
Imagine a type decorator:
class FancyDict(TypeDecorator[Dict[str, Any]]):
impl = Unicode
def process_bind_param(self, value, dialect):
...
def process_result_value(self, value, dialect) -> Dict[str, Any]: # note non-optional return
if value:
return json.loads(value)
return {}
For such types a column should be considered non-optional even if it is nullable. This looks like a work for plugin.