astroid icon indicating copy to clipboard operation
astroid copied to clipboard

Turn `ImportFrom.names` into a list of `NamedTuple`

Open tristanlatr opened this issue 4 years ago • 1 comments

Current behavior

Each entry is a tuple of the name being imported, and the alias that the name is assigned to (if any).

Expected behavior

Have something that acts like an ast.alias object. So that could be acheived by using NamedTuple, this would keep the compatibility with the normal tuple usage and would allow to be used like it was an ast.alias object, such that less effort is needed to adopt astroid.

alias = namedtuple('alias', ('name', 'asname'))

Astroid version: 2.9.3

tristanlatr avatar Jan 11 '22 23:01 tristanlatr

In theory it's a good idea. However I would prefer not to change it before the Import nodes are re-done at some point. We may want to add a dedicated node class for Alias, having a NamedTuple with the same name could be confusing.

cdce8p avatar Jan 31 '22 18:01 cdce8p