From 4bf3d389398db248d1989d884d62c24e27c83d9c Mon Sep 17 00:00:00 2001
From: Kaushik Kulkarni <kaushikcfd@gmail.com>
Date: Wed, 9 Nov 2022 10:14:54 -0600
Subject: [PATCH] do not rewrite properties

---
 pymbolic/mapper/optimize.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pymbolic/mapper/optimize.py b/pymbolic/mapper/optimize.py
index e32f084..16b796a 100644
--- a/pymbolic/mapper/optimize.py
+++ b/pymbolic/mapper/optimize.py
@@ -21,7 +21,7 @@ THE SOFTWARE.
 """
 
 import ast
-from functools import lru_cache
+from functools import lru_cache, cached_property
 
 
 # This machinery applies AST rewriting to the mapper in a mildly brutal
@@ -270,6 +270,10 @@ def optimize_mapper(
         for name in dir(cls):
             if not name.startswith("__") or name == "__call__":
                 method = getattr(cls, name)
+                if isinstance(method, (property, cached_property)):
+                    # properties don't have *args, **kwargs
+                    continue
+
                 seen_module_names.add(method.__module__)
                 method_ast = _get_ast_for_method(method)
                 if name != method_ast.name:
-- 
GitLab