ソースを参照

Merge pull request #339 from exponea/fix-class-v-args-non-methods

Fix v_args when used on classes with non-callable members
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.0
Erez Shinan 5年前
committed by GitHub
コミット
c0810d1982
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
2個のファイルの変更4行の追加0行の削除
  1. +2
    -0
      lark/visitors.py
  2. +2
    -0
      tests/test_trees.py

+ 2
- 0
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'):


+ 2
- 0
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)


読み込み中…
キャンセル
保存