pylint-dev / pylint-dev/astroid

[bug] tolineno value differs from ast end_lineno on multi-line statements

Open
#784 1 comment 0 reactions 0 assignees View on GitHub
T: Line numbering
Dominant language
Python
Stars
582
Forks
357
Avg merge
1d 1h
Merged PRs (30d)
23

Description

Parsing multi-line statements result in an incorrect value of 'tolineno'. However, the ast module of Python does return the correct value.

Example of such multi-line statement:
```python
"".join(
["", ""]
)
```

### Steps to reproduce
```python
import ast
import astroid
tree_ast = ast.parse('"".join(\n\t["", ""]\n)')
tree_astroid = astroid.parse('"".join(\n\t["", ""]\n)')
tree_ast.body[0].value.end_lineno
Out[6]: 3
tree_astroid.body[0].value.tolineno
Out[7]: 2
```

### Current behavior
In the above example, `tree_astroid.body[0].value.tolineno` returns `2`.

### Expected behavior
In the above example, `tree_astroid.body[0].value.tolineno` should also return `3`.

### Version
2.4.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.