mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-99341: Cover type ignore nodes when incrementing line numbers (GH-99422)
This commit is contained in:
parent
bc3a11d21d
commit
1acdfec359
3 changed files with 20 additions and 0 deletions
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue