diff --git a/experiments/__doc__/coverage_mcpyrate/mymacros.py b/experiments/__doc__/coverage_mcpyrate/mymacros.py index 8d4bcf7b..87036431 100644 --- a/experiments/__doc__/coverage_mcpyrate/mymacros.py +++ b/experiments/__doc__/coverage_mcpyrate/mymacros.py @@ -1,5 +1,6 @@ from ast import (Assign, Name, Attribute, Expr, Num, Str, NameConstant, copy_location, walk) from mcpyrate.quotes import macros, q, u, n, a # noqa: F401 +from mcpyrate.astfixers import fix_locations import mcpyrate # noqa: F401 @@ -48,8 +49,7 @@ def document(tree, **kw): with q as quoted: n[name] = u[type_hint + s.value.s.rstrip()] tree[index] = quoted[0] - for node in walk(tree[index]): - copy_location(node, s) + fix_locations(tree[index], s, mode="overwrite") prev = s # Return the modified AST return tree diff --git a/kibot/macros.py b/kibot/macros.py index 6d2e390f..73e7c4b1 100644 --- a/kibot/macros.py +++ b/kibot/macros.py @@ -12,6 +12,7 @@ from ast import (Assign, Name, Attribute, Expr, Num, Str, NameConstant, Load, St from .mcpyrate import unparse from .mcpyrate.quotes import macros, q, u, n, a # noqa: F401 from .mcpyrate.splicing import splice_statements +from .mcpyrate.astfixers import fix_locations from . import mcpyrate # noqa: F401 @@ -79,8 +80,7 @@ def document(sentences, **kw): name = 'self.'+doc_id if is_attr else doc_id with q as quoted: n[name] = u[type_hint+s.value.s.rstrip()+post_hint] - for node in walk(quoted[0]): - copy_location(node, s) + fix_locations(quoted[0], s, mode="overwrite") sentences[index] = quoted[0] else: # Transform the string into an assign for _help_ID