Skip to content

Conversation

@smaye81
Copy link
Contributor

@smaye81 smaye81 commented Jul 31, 2025

This adds re2 as an optional dependency to protovalidate-python. With this configured, users can choose to optionally install re2 if they explicit re2 functionality.

For example

pip install protovalidate[re2]

Note that while CEL requires re2 as part of the spec, our current version of cel-python (v0.2.0) doesn't. We are unable to upgrade cel-python beyond v0.2.0 at this point due to some outstanding issues, so since re2 now supports Python 3.13, we're adding it as an optional dep directly to protovalidate-python rather than the re2 workaround we had previously implemented.

Copy link
Member

@stefanvanburen stefanvanburen left a comment

Choose a reason for hiding this comment

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

lgtm, one nit on testextra but otherwise exactly what I was envisioning

Makefile Outdated

.PHONY: testextra
testextra:
uv pip install .[re2]
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to avoid uv pip, and instead do something like uv sync --extra re2?: https://docs.astral.sh/uv/concepts/projects/sync/#syncing-optional-dependencies

from protovalidate.internal.extra_func import cel_matches_re, cel_matches_re2

_USE_RE2 = True
spec = importlib.util.find_spec("re2")
Copy link
Member

Choose a reason for hiding this comment

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


_USE_RE2 = True
try:
import re2 # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

one other minor thing, if we want: could install the google-re2-stubs package as a dev dependency, which would give us type info for re2 (and we could nix the ignore here).

ref: https://github.com/ddn0/google-re2-stubs

Copy link
Member

Choose a reason for hiding this comment

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

(published by the same person who had asked for re2 compatibility, here: #145)

@smaye81 smaye81 requested a review from stefanvanburen July 31, 2025 19:04
@smaye81 smaye81 merged commit eb3c727 into main Jul 31, 2025
12 checks passed
@smaye81 smaye81 deleted the sayers/re2_extra branch July 31, 2025 19:32
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.

3 participants