From b89b003cdb8d2d1b0f0041429814ac9989781a40 Mon Sep 17 00:00:00 2001 From: Peter Dolak Date: Wed, 13 Mar 2019 11:36:54 +0100 Subject: [PATCH] Fix v_args when used on classes with non-callable members --- lark/visitors.py | 2 ++ tests/test_trees.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lark/visitors.py b/lark/visitors.py index 26ca242..71dfd42 100644 --- a/lark/visitors.py +++ b/lark/visitors.py @@ -74,6 +74,8 @@ class Transformer: for name, value in getmembers(cls): if name.startswith('_') or name in libmembers: continue + if not callable(cls.__dict__[name]): + continue # Skip if v_args already applied (at the function level) if hasattr(cls.__dict__[name], 'vargs_applied'): diff --git a/tests/test_trees.py b/tests/test_trees.py index e5008ef..38f74d5 100644 --- a/tests/test_trees.py +++ b/tests/test_trees.py @@ -137,6 +137,8 @@ class TestTrees(TestCase): f = float sub = lambda self, a, b: a-b + not_a_method = {'other': 'stuff'} + @v_args(inline=False) def add(self, values): return sum(values)