Skip to content

Commit 45b60d2

Browse files
Remove re2 fallback to re behavior
Unnecessary after cloud-custodian#127. Moves function_matches back in place with the other cel functions. Also, remove the documented fallback behavior from the README.
1 parent 24ab9c4 commit 45b60d2

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

README.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@ CEL specifies that regular expressions use re2 syntax,
4545
https://github.com/google/re2/wiki/Syntax.
4646
As of the 0.4.0 release, the Google-RE2 module is part of the CEL distribution.
4747

48-
.. warning:: Apple Silicon and Python 3.13
49-
50-
See https://github.com/google/re2/issues/453,
51-
https://github.com/google/re2/issues/346,
52-
https://github.com/google/re2/issues/516
53-
54-
Google-RE2 does not build for Python 3.13 on the "darwin" platform with the "arm64" architecture.
55-
Currently, there is no pre-built binary for Python 3.13.
56-
57-
The built-in ``re`` is used as a fall-back, and does work for all but a few edge cases.
58-
5948
Command Line
6049
============
6150

src/celpy/evaluation.py

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
import operator
5656
import os
5757
import re
58-
from string import Template
5958
import sys
6059
from functools import reduce, wraps
60+
from string import Template
6161
from textwrap import dedent
6262
from typing import (
6363
Any,
@@ -80,37 +80,11 @@
8080

8181
import lark
8282
import lark.visitors
83+
import re2
8384

8485
import celpy.celtypes
8586
from celpy.celparser import tree_dump
8687

87-
try:
88-
import re2
89-
90-
def function_matches(text: str, pattern: str) -> "Result":
91-
"""Implementation of the ``match()`` function using ``re2``"""
92-
try:
93-
m = re2.search(pattern, text)
94-
except re2.error as ex:
95-
return CELEvalError("match error", ex.__class__, ex.args)
96-
97-
return celpy.celtypes.BoolType(m is not None)
98-
99-
except ImportError: # pragma: no cover
100-
# There is a build issue with python_version=='3.13' and sys_platform=='darwin'
101-
# See https://github.com/google/re2/issues/516
102-
# We fall back to using re, which passes the essential tests
103-
104-
def function_matches(text: str, pattern: str) -> "Result":
105-
"""Alternative implementation of the ``match()`` function for systems where ``re2`` can't be installed."""
106-
try:
107-
m = re.search(pattern, text)
108-
except re.error as ex:
109-
return CELEvalError("match error", ex.__class__, ex.args)
110-
111-
return celpy.celtypes.BoolType(m is not None)
112-
113-
11488
# An Annotation describes a union of types, functions, and function types.
11589
Annotation = Union[
11690
celpy.celtypes.TypeType,
@@ -420,6 +394,16 @@ def function_endsWith(
420394
return celpy.celtypes.BoolType(string.endswith(fragment))
421395

422396

397+
def function_matches(text: str, pattern: str) -> Result:
398+
"""Implementation of the ``match()`` function using ``re2``"""
399+
try:
400+
m = re2.search(pattern, text)
401+
except re2.error as ex:
402+
return CELEvalError("match error", ex.__class__, ex.args)
403+
404+
return celpy.celtypes.BoolType(m is not None)
405+
406+
423407
def function_getDate(
424408
ts: celpy.celtypes.TimestampType,
425409
tz_name: Optional[celpy.celtypes.StringType] = None,

0 commit comments

Comments
 (0)