summaryrefslogtreecommitdiffstats
path: root/Lib/ast.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ast.py')
-rw-r--r--Lib/ast.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/ast.py b/Lib/ast.py
index 1a94e93..2cbc80a 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -237,6 +237,12 @@ def increment_lineno(node, n=1):
location in a file.
"""
for child in walk(node):
+ # TypeIgnore is a special case where lineno is not an attribute
+ # but rather a field of the node itself.
+ if isinstance(child, TypeIgnore):
+ child.lineno = getattr(child, 'lineno', 0) + n
+ continue
+
if 'lineno' in child._attributes:
child.lineno = getattr(child, 'lineno', 0) + n
if (