Use re2 instead of re for match expressions
CEL specifies that match should use re2 pattern matching and not re semantics.
Closes https://github.com/cloud-custodian/cel-python/issues/58
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: slott56 / name: S.Lott (12a792fdf96469c45b46449ccdeb47a39ab50309, 3bd13db7e312b1b277cf3b58838cca48a61b6b4a, 6d097e7ac4e89d06d42521d752f901e2d45b7205)
- :white_check_mark: login: ddn0 / name: Donald Nguyen (100ea21c17929a58198a0ba862efee2f5d834b12)
CEL specifies that match should use re2 pattern matching and not re semantics.
Although it's obvious that the language definition specifies RE2 syntax for regular expressions, it's possibly less obvious that all of the aforementioned Python wrappers are precisely that: Python wrappers... around RE2, the C++ library. Given that this project aims to be pure Python and to have minimal dependencies, it's worth noting what might be a necessary compromise.
Given that this project aims to be pure Python and to have minimal dependencies, it's worth noting what might be a necessary compromise.
I don't have much context about the north star of "pure Python and minimal dependencies", but if we want to maintain that, I can add the re2 capability as a package extra.
@slott56 ready for re-review.
Some questions: when I ran black or ruff I get a bunch of unrelated formatting changes which makes me think my configuration is wrong somehow. black isn't mentioned in pyproject.toml so maybe there is a difference between my local version and the one that has been used on the repo so far?
Anyway, I manually applied a style which I hope is compatible with the repo style, but let me know if you have any guidance on checking the formatting style automatically.
Black has (almost) no configuration, which is why it's widely used. We don't include a format check on this repository right now, but we will in the future. I need to confirm Kapil's preference (Ruff Format vs. Black) before I enable it.
Black has (almost) no configuration, which is why it's widely used. We don't include a format check on this repository right now, but we will in the future. I need to confirm Kapil's preference (Ruff Format vs. Black) before I enable it.
Cool. If it helps, in my other projects, we transitioned from black to ruff format because we were already using ruff for linting and the standard ruff format configuration is supposed to be black compatible, so one less tool in the toolchain. ruff format optionally formats code examples in docstrings, which was relevant for my other projects.
@slott56 ping. Any changes you want to request?
@ddn0 thanks for the updates and making a re2 stub package.
Hello @slott56 ; would it be possible to merge this PR in order to make cel-python compliant with the standard?
Bumping this again. Would it be possible to get this merged @slott56 ?
@ddn0: I think it would be best if you upgrade to Poetry 2.1.3 so it tweaks the locks and the pyproject.toml. (Not rock-solid sure about this approach, but that seems to be what the 3.12 test case requires.)
Sorry @slott56 , I didn't see this in time to help :D My github notifications are pretty noisy. Looks like you figured it out, thanks so much!