Skip to content

Commit 84622a6

Browse files
author
Steve Ayers
committed
Remove re2
1 parent ae3e3df commit 84622a6

File tree

7 files changed

+6
-115
lines changed

7 files changed

+6
-115
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
# Note we can't test above v3.12 because google-re2 does not have a
21-
# built wheel beyond 3.12 on PyPI
22-
python-version: ["3.9", "3.10", "3.11", "3.12"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2321
steps:
2422
- name: Checkout code
2523
uses: actions/checkout@v4

.github/workflows/conformance.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
# Note we can't test above v3.12 because google-re2 does not have a
21-
# built wheel beyond 3.12 on PyPI
22-
python-version: ["3.9", "3.10", "3.11", "3.12"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2321
steps:
2422
- name: Checkout code
2523
uses: actions/checkout@v4

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python
2323
uses: actions/setup-python@v5
2424
with:
25-
python-version: "3.12"
25+
python-version: "3.13"
2626
- name: Install pypa/build
2727
run: |
2828
python -m pip install build

Pipfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ name = "pypi"
66
[packages]
77
cel-python = "==0.2.*"
88
protobuf = "==6.*"
9-
google-re2 = "*"
109

1110
[dev-packages]
12-
google-re2-stubs = "*"
1311
pytest = "*"
1412
mypy = "*"
1513
ruff = "*"

Pipfile.lock

Lines changed: 1 addition & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protovalidate/internal/extra_func.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,22 @@
1313
# limitations under the License.
1414

1515
import math
16+
import re
1617
import typing
1718
from urllib import parse as urlparse
1819

1920
import celpy
20-
import re2
2121
from celpy import celtypes
2222

2323
from protovalidate.internal import string_format
2424
from protovalidate.internal.rules import MessageType, field_to_cel
2525

2626
# See https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
27-
_email_regex = re2.compile(
27+
_email_regex = re.compile(
2828
r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
2929
)
3030

3131

32-
# Currently cel-python does not support re2. So we are overriding their `matches`
33-
# function with our own that leverages re2. Note there is a PR in cel-python to
34-
# add re2 support. See https://github.com/cloud-custodian/cel-python/pull/67.
35-
# Once that lands, this `matches` override can be removed.
36-
def cel_matches(text: str, pattern: str) -> celpy.Result:
37-
try:
38-
m = re2.search(pattern, text)
39-
except re2.error as ex:
40-
msg = "match error"
41-
raise celpy.CELEvalError(msg, ex.__class__, ex.args) from ex
42-
return celtypes.BoolType(m is not None)
43-
44-
4532
def cel_get_field(message: celtypes.Value, field_name: celtypes.Value) -> celpy.Result:
4633
if not isinstance(message, MessageType):
4734
msg = "invalid argument, expected message"
@@ -1573,7 +1560,6 @@ def make_extra_funcs(locale: str) -> dict[str, celpy.CELFunction]:
15731560
return {
15741561
# Missing standard functions
15751562
"format": string_fmt.format,
1576-
"matches": cel_matches,
15771563
# protovalidate specific functions
15781564
"getField": cel_get_field,
15791565
"isNan": cel_is_nan,

tests/matches_test.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)