Make Asty use static rather than instance methods
This ensures `asty.Pass is asty.Pass`.
This commit is contained in:
parent
d3bd7c1017
commit
844256b99b
@ -111,13 +111,13 @@ def builds_model(*model_types):
|
|||||||
# ast.Foo(..., lineno=x.lineno, col_offset=x.col_offset)
|
# ast.Foo(..., lineno=x.lineno, col_offset=x.col_offset)
|
||||||
class Asty(object):
|
class Asty(object):
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
setattr(Asty, name, lambda self, x, **kwargs: getattr(ast, name)(
|
setattr(Asty, name, staticmethod(lambda x, **kwargs: getattr(ast, name)(
|
||||||
lineno=getattr(
|
lineno=getattr(
|
||||||
x, 'start_line', getattr(x, 'lineno', None)),
|
x, 'start_line', getattr(x, 'lineno', None)),
|
||||||
col_offset=getattr(
|
col_offset=getattr(
|
||||||
x, 'start_column', getattr(x, 'col_offset', None)),
|
x, 'start_column', getattr(x, 'col_offset', None)),
|
||||||
**kwargs))
|
**kwargs)))
|
||||||
return getattr(self, name)
|
return getattr(Asty, name)
|
||||||
asty = Asty()
|
asty = Asty()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user