Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 00db6e8

Browse files
author
Juanjo Alvarez
committed
Fix position from ImportFrom nodes
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 4c54de8 commit 00db6e8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

native/python_package/python_driver/astimprove.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
AstDict = Dict[Any, Any]
2222
VisitResult = Union[Node, List[Node]]
2323

24-
2524
class TokenPos():
2625
def __init__(self, row: int, col: int) -> None:
2726
self.row = row
@@ -152,8 +151,11 @@ def sync_node_pos(self, nodedict: Node) -> None:
152151
# position in that case is fine (uses the last line in that case)
153152
return
154153

155-
nodedict["lineno"] = token.start.row
156-
nodedict["col_offset"] = token.start.col
154+
if nodedict['ast_type'] != 'ImportFrom':
155+
# ImportFrom takes the module as token, we don't want that position, default
156+
# is fine
157+
nodedict["lineno"] = token.start.row
158+
nodedict["col_offset"] = token.start.col
157159
nodedict["end_lineno"] = token.end.row
158160
nodedict["end_col_offset"] = token.end.col
159161

0 commit comments

Comments
 (0)