diff --git a/kibot/macros.py b/kibot/macros.py index 97b312fc..a104a435 100644 --- a/kibot/macros.py +++ b/kibot/macros.py @@ -101,7 +101,8 @@ def _do_wrap_class_register(tree, mod, base_class): # Function call to it passing reg_name and name do_register = Expr(value=Call(func=attr, args=[Str(s=reg_name), Name(id=name, ctx=Load())], keywords=[])) # Create the import - do_import = ImportFrom(module=mod, names=[alias(name=base_class, asname=None)], level=1) + do_import = ImportFrom(module=mod, names=[alias(name=base_class, asname=None, lineno=tree.lineno, + col_offset=tree.col_offset)], level=1) return [do_import, tree, do_register] # Just in case somebody applies it to anything other than a class return tree diff --git a/kibot/mcpyrate/expander.py b/kibot/mcpyrate/expander.py index e760f45e..d4c081db 100644 --- a/kibot/mcpyrate/expander.py +++ b/kibot/mcpyrate/expander.py @@ -649,8 +649,12 @@ def find_macros(tree, *, filename, reload=False, self_module=None, transform=Tru else: # Remove all names to prevent macros being used as regular run-time objects. # Always use an absolute import, for the unhygienic expose API guarantee. - tree.body[index] = copy_location(Import(names=[alias(name=module_absname, asname=None)]), - statement) + tree.body[index] = copy_location(Import(names=[ + alias(name=module_absname, + asname=None, + lineno=getattr(statement, 'lineno', 0), + col_offset=getattr(statement, 'col_offset', 0))]), + statement) for index in reversed(stmts_to_delete): tree.body.pop(index) return bindings