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

Typing overloads for ge, gt, le, lt, eq, ne #13166

Closed
s-banach opened this issue Dec 21, 2023 · 0 comments · Fixed by #13167
Closed

Typing overloads for ge, gt, le, lt, eq, ne #13166

s-banach opened this issue Dec 21, 2023 · 0 comments · Fixed by #13167
Labels
enhancement New feature or an improvement of an existing feature

Comments

@s-banach
Copy link
Contributor

s-banach commented Dec 21, 2023

Description

For example, __ge__ is annotated as follows:

    @overload
    def __ge__(self, other: Expr) -> Expr:  # type: ignore[overload-overlap]
        ...

    @overload
    def __ge__(self, other: Any) -> Series:
        ...

Where as ge is annotated like this:

    def ge(self, other: Any) -> Self | Expr:
        """Method equivalent of operator expression `series >= other`."""
        return self.__ge__(other)

Now this is partially a question about how other type checkers work. My experience with Pylance is that I'm going to get a type error from the following code, because x.gt(0).all() could be an Expr:

x = pl.Series(...)
if x.ge(0).all():
    ...

Is this also the case for other type checkers? If so, I can make a quick PR to add these overloads.
(Ironically, I believe Pylance would infer the correct types if ge simply had no annotations at all.)

@s-banach s-banach added the enhancement New feature or an improvement of an existing feature label Dec 21, 2023
@s-banach s-banach changed the title Typing overloads for ge, gt, le, lt, ne, etc. Typing overloads for ge, gt, le, lt, eq, ne Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant