diff options
author | Batuhan Taskaya <isidentical@gmail.com> | 2022-11-22 10:41:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 10:41:14 (GMT) |
commit | 1acdfec359fdf3db936168480be0f4157273c200 (patch) | |
tree | ecc1f515cee2ebfe1e5f740af7b828775a8fd7e2 /Lib/ast.py | |
parent | bc3a11d21ddef28047b18c0f6a5068fa9fb16da2 (diff) | |
download | cpython-1acdfec359fdf3db936168480be0f4157273c200.zip cpython-1acdfec359fdf3db936168480be0f4157273c200.tar.gz cpython-1acdfec359fdf3db936168480be0f4157273c200.tar.bz2 |
gh-99341: Cover type ignore nodes when incrementing line numbers (GH-99422)
Diffstat (limited to 'Lib/ast.py')
-rw-r--r-- | Lib/ast.py | 6 |
1 files changed, 6 insertions, 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 ( |