You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
assignee=Noneclosed_at=<Date2021-04-10.20:57:20.714>created_at=<Date2021-04-09.20:28:56.470>labels= ['interpreter-core', 'type-feature', '3.10']
title='Add position metadata to alias AST type'updated_at=<Date2021-04-14.15:03:48.078>user='https://github.com/msuozzo'
Given the increasing use of long from typing import foo, bar, ... import sequences, it's becoming more desirable to address individual components of the import node. Unfortunately, the ast.alias node doesn't contain source location metadata (e.g. lineno, col_offset).
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.
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.
Activity
msuozzo commentedon Apr 9, 2021
Given the increasing use of long
from typing import foo, bar, ...import sequences, it's becoming more desirable to address individual components of the import node. Unfortunately, the ast.alias node doesn't contain source location metadata (e.g. lineno, col_offset).This metadata would be comparatively easy to add, backwards compatible, and would enable more precise diagnostics e.g. lints.
msuozzo commentedon Apr 9, 2021
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.
lysnikolaou commentedon Apr 9, 2021
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).
pablogsal commentedon Apr 9, 2021
Unfortunately no, is technically a new feature.
lysnikolaou commentedon Apr 10, 2021
New changeset 75a06f0 by Matthew Suozzo in branch 'master':
bpo-43798: Add source location attributes to alias (GH-25324)
75a06f0
hauntsaninja commentedon Apr 11, 2021
FYI, probably unavoidable, but this appears to have broken pytest pytest-dev/pytest#8539
pablogsal commentedon Apr 11, 2021
What's the problem? alias objects *have* lineno argument:
blueyed commentedon Apr 12, 2021
@pablo: the problem (referenced in the pytest issue) is that
ast.aliashas new required arguments now (see also the adjusted test in75a06f0#diff-3f516b60719dd445d33225e4f316b36e85c9c51a843a0147349d11a005c55937R1060-R1061). That's expected/wanted though (assuming that it should not have "defaults" for B/C), and there's a patch for the issue at pytest-dev/pytest#8540.
pablogsal commentedon Apr 12, 2021
Ah, it was not clear from the issue that pytest was constructing nodes by hand. It makes sense now. Thanks!