Skip to content

Is the return-type of process_bind_param correct? #212

@exhuma

Description

@exhuma

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions