Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the return-type of process_bind_param correct? #212

Closed
exhuma opened this issue Mar 5, 2021 · 2 comments
Closed

Is the return-type of process_bind_param correct? #212

exhuma opened this issue Mar 5, 2021 · 2 comments

Comments

@exhuma
Copy link

exhuma commented Mar 5, 2021

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
Copy link

huonw commented Apr 26, 2021

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
Copy link
Author

exhuma commented Jun 25, 2021

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

@exhuma exhuma closed this as completed Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants