sqlalchemy-stubs icon indicating copy to clipboard operation
sqlalchemy-stubs copied to clipboard

Infer non-optional types for some type decorators

Open ilevkivskyi opened this issue 6 years ago • 0 comments

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.

ilevkivskyi avatar Jan 22 '19 19:01 ilevkivskyi