ibis-project / ibis

the portable Python dataframe library
https://ibis-project.org
Apache License 2.0
4.3k stars 537 forks source link

bug: typing issue with `filter` method on the table column #9108

Closed fwojciec closed 2 weeks ago

fwojciec commented 2 weeks ago

What happened?

Screenshot 2024-05-02 at 10 25 53 AM

Here is a repo with the reproduction of the issue on the screenshot: https://github.com/fwojciec/ibis-types-test

Legitimate uses of the filter method result in type errors reported by pyright and pylance. This is because the filter method expects the predicates to be ir.BooleanValue | Sequence[ir.BooleanValue] | IfAnyAll and the actual type of the predicates in the above examples is just a plain ol' bool.

Interestingly, the equals method provided by Ibis returns b bool for its result, which seems like an inconsistency.

I appreciate that static typing is not a priority for the project, so I'm happy to make a PR to try and fix any typing issues I come across, but I wanted to get some guidance first on how these types of issues should be addressed - in this case, is the solution basically adding bool as a type that's accepted by the filter method in addition to the internal Ibis types mentioned above? Or maybe this is just something that can be worked around by somehow casting the bool predicate into an instance of BooleanValue? Are there any documents/references I should look up to understand how static typing is supposed to work in Ibis?

What version of ibis are you using?

ibis-framework[duckdb]>=9.0.0 specifically - on 9.0.0 right now

What backend(s) are you using, if any?

DuckDB

Relevant log output

No response

Code of Conduct

jcrist commented 2 weeks ago

Hi - thanks for opening this. Two things:

fwojciec commented 2 weeks ago

Thanks for the feedback - it all makes sense. I'm happy to close this as this is not really a bug, and I see if I can come up with a PR that addresses the specific issue here.