From b08b1104f19cc8e4e6496a10ff0c266fcc8050d5 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 23 Oct 2020 19:50:13 -0300 Subject: [PATCH] Modified to use fix_locations instead of a manual loop. --- experiments/__doc__/coverage_mcpyrate/mymacros.py | 4 ++-- kibot/macros.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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