New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add position metadata to alias AST type #87964
Comments
Given the increasing use of long This metadata would be comparatively easy to add, backwards compatible, and would enable more precise diagnostics e.g. lints. |
Ah and one other question: Is this normally the sort of thing that would get backported? It should be very straightforward to do so, at least for 3.9 given the support for the new parser. |
I'm okay with this, unless someone has any input on why the alias node should not have line/column info (and did not have it in the first place). |
Unfortunately no, is technically a new feature. |
FYI, probably unavoidable, but this appears to have broken pytest pytest-dev/pytest#8539 |
What's the problem? alias objects *have* lineno argument: >>> print(ast.dump(ast.parse("from x import y"), include_attributes=True, indent=4))
Module(
body=[
ImportFrom(
module='x',
names=[
alias(
name='y',
lineno=1,
col_offset=14,
end_lineno=1,
end_col_offset=15)],
level=0,
lineno=1,
col_offset=0,
end_lineno=1,
end_col_offset=15)],
type_ignores=[]) |
@pablo: the problem (referenced in the pytest issue) is that |
Ah, it was not clear from the issue that pytest was constructing nodes by hand. It makes sense now. Thanks! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: