From 2342c130d6a5f4f81dedc0756062a2510159d839 Mon Sep 17 00:00:00 2001 From: "S.Lott" Date: Wed, 21 May 2025 11:11:51 -0400 Subject: [PATCH] Update for 0.3.0 release Touch `pyproject.toml`, `tox.ini` and reformat src files. --- .gitignore | 2 ++ pyproject.toml | 2 +- src/celpy/evaluation.py | 28 ++++++++++++++++++++++------ tox.ini | 2 +- type_check/lineprecision.txt | 16 ++++++++-------- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 120531f..5462dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,5 @@ type_check/lineprecision.txt # PyCharm Stuff .idea/* demo/issue_41.py +demo/issue_80.py +setup.sh diff --git a/pyproject.toml b/pyproject.toml index d3d962b..ba46836 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ [tool.poetry] name = "cel-python" -version = "0.2.0" +version = "0.3.0" description = "Pure Python implementation of Google Common Expression Language" authors = ["S. Lott "] readme = "README.rst" diff --git a/src/celpy/evaluation.py b/src/celpy/evaluation.py index afe461a..cf91645 100644 --- a/src/celpy/evaluation.py +++ b/src/celpy/evaluation.py @@ -2030,7 +2030,15 @@ def member_dot_arg(self, tree: lark.Tree) -> Result: Tuple[lark.Tree, lark.Token], tree.children[:2] ) - if method_name_token.value in {"map", "filter", "all", "exists", "exists_one", "reduce", "min"}: + if method_name_token.value in { + "map", + "filter", + "all", + "exists", + "exists_one", + "reduce", + "min", + }: member_list = cast(celpy.celtypes.ListType, self.visit(member_tree)) if isinstance(member_list, CELEvalError): @@ -2038,7 +2046,9 @@ def member_dot_arg(self, tree: lark.Tree) -> Result: if method_name_token.value == "map": sub_expr = self.build_macro_eval(tree) - mapping = cast(Iterable[celpy.celtypes.Value], map(sub_expr, member_list)) + mapping = cast( + Iterable[celpy.celtypes.Value], map(sub_expr, member_list) + ) result = celpy.celtypes.ListType(mapping) return result @@ -2052,9 +2062,12 @@ def member_dot_arg(self, tree: lark.Tree) -> Result: and_oper = cast( CELBoolFunction, eval_error("no such overload", TypeError)( - celpy.celtypes.logical_and) + celpy.celtypes.logical_and + ), + ) + reduction = reduce( + and_oper, map(sub_expr, member_list), celpy.celtypes.BoolType(True) ) - reduction = reduce(and_oper, map(sub_expr, member_list), celpy.celtypes.BoolType(True)) return reduction elif method_name_token.value == "exists": @@ -2062,9 +2075,12 @@ def member_dot_arg(self, tree: lark.Tree) -> Result: or_oper = cast( CELBoolFunction, eval_error("no such overload", TypeError)( - celpy.celtypes.logical_or) + celpy.celtypes.logical_or + ), + ) + reduction = reduce( + or_oper, map(sub_expr, member_list), celpy.celtypes.BoolType(False) ) - reduction = reduce(or_oper, map(sub_expr, member_list), celpy.celtypes.BoolType(False)) return reduction elif method_name_token.value == "exists_one": diff --git a/tox.ini b/tox.ini index f77b024..e6243aa 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ [tox] skipsdist = true -envlist = py38,py39,py310,py311,py312,lint +envlist = py38,py39,py310,py311,py312,py313,lint minversion = 4.15.0 [testenv] diff --git a/type_check/lineprecision.txt b/type_check/lineprecision.txt index 5e06b3b..e6e864d 100644 --- a/type_check/lineprecision.txt +++ b/type_check/lineprecision.txt @@ -1,11 +1,11 @@ Name Lines Precise Imprecise Any Empty Unanalyzed ------------------------------------------------------------------- -celpy 293 76 0 4 213 0 -celpy.__main__ 465 172 7 42 244 0 -celpy.adapter 137 35 3 9 85 5 -celpy.c7nlib 1584 340 15 154 1075 0 -celpy.celparser 401 207 2 22 170 0 -celpy.celtypes 1503 438 14 221 791 39 -celpy.evaluation 2472 835 33 177 1411 16 +celpy 306 76 0 4 226 0 +celpy.__main__ 508 204 8 42 254 0 +celpy.adapter 141 34 3 9 89 6 +celpy.c7nlib 1663 351 14 149 1149 0 +celpy.celparser 388 199 3 22 164 0 +celpy.celtypes 1504 417 14 224 812 37 +celpy.evaluation 2578 862 38 177 1483 18 xlate 0 0 0 0 0 0 -xlate.c7n_to_cel 1730 377 102 145 1101 5 +xlate.c7n_to_cel 1755 385 103 146 1115 6