Browse Source
Merge pull request #102 from night199uk/functools
Allow functools partials to be used with the InlineTransformer
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.6
Erez Shinan
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
0 deletions
-
lark/utils.py
|
|
@@ -71,6 +71,12 @@ def inline_args(f): |
|
|
|
def _f(self, args): |
|
|
|
return f.__func__(self, *args) |
|
|
|
return _f |
|
|
|
elif isinstance(f, functools.partial): |
|
|
|
# wraps does not work for partials in 2.7: https://bugs.python.org/issue3445 |
|
|
|
# @functools.wraps(f) |
|
|
|
def _f(self, args): |
|
|
|
return f(*args) |
|
|
|
return _f |
|
|
|
else: |
|
|
|
@functools.wraps(f.__call__.__func__) |
|
|
|
def _f(self, args): |
|
|
|