Skip to content

Conversation

@alukach
Copy link
Member

@alukach alukach commented Mar 26, 2025

Stumbled my way through this, would appreciate guidance on if there is a more idiomatic way to achieve the pyo3 logic.

Stumbled my way through this, would appreciate guidance on if there is a more idiomatic way to achieve the pyo3 logic.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new function, reduce, to the Python bindings in order to expose pyo3 logic for expression reduction.

  • Added a new reduce function to the Expr struct in python/src/lib.rs.
  • Updated the type hints and documentation in cql2.pyi to support the new function and improve type consistency.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
python/src/lib.rs Added the reduce function with de-pythonizing of input and error mapping.
cql2.pyi Added a reduce method signature and updated add type annotation.
Comments suppressed due to low confidence (2)

python/src/lib.rs:95

  • [nitpick] If self.0 can be used without cloning, consider refactoring to avoid unnecessary cloning which might result in performance overhead.
.clone().reduce(value.as_ref())

cql2.pyi:137

  • Using bare 'Expr' assumes that Expr is already defined; if it isn't, consider using a forward reference (e.g., "Expr") for compatibility with static type checkers.
def __add__(self, other: Expr) -> Expr:

Co-authored-by: Kyle Barron <kyle@developmentseed.org>
@alukach alukach enabled auto-merge (squash) March 27, 2025 19:29
@alukach alukach merged commit e563fcd into main Mar 27, 2025
1 check passed
@alukach alukach deleted the py/reduce branch March 27, 2025 19:31
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

Successfully merging this pull request may close these issues.

4 participants