dropbox / sqlalchemy-stubs

Mypy plugin and stubs for SQLAlchemy
Apache License 2.0
570 stars 101 forks source link

Is the return-type of process_bind_param correct? #212

Closed exhuma closed 3 years ago

exhuma commented 3 years ago

here the return type is defines as typing_Text and I'm not sure if that's correct. If I have the following type-decorator I get a typing error but the code works:

class DbInfiniteInt(TypeDecorator):  # type: ignore
    """
    A codec which maps a database integer value to "MaybeInfiniteInt"
    """

    impl = Integer

    def process_bind_param(
        self, 
        value: Optional[MaybeInfiniteInt],
        dialect: Dialect,
    ) -> Optional[int]:  # <-- mypy complains about this return-type
        if value is None:
            return None
        if value.is_infinite():
            return -1
        return int(value)
huonw commented 3 years ago

I think you're right, that it's not. We've had to use # type: ignore on our process_bind_param functions. (I think this is a duplicate of #205 and #206.)

exhuma commented 3 years ago

You're right. It's a duplicate. I'm closing this in favour of #205