Skip to content

Turn ImportFrom.names into a list of NamedTuple #1339

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

Open
tristanlatr opened this issue Jan 11, 2022 · 1 comment
Open

Turn ImportFrom.names into a list of NamedTuple #1339

tristanlatr opened this issue Jan 11, 2022 · 1 comment
Labels
Enhancement ✨ Improvement to a component

Comments

@tristanlatr
Copy link
Contributor

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

@DanielNoord DanielNoord added the Enhancement ✨ Improvement to a component label Jan 12, 2022
@cdce8p
Copy link
Member

cdce8p commented Jan 31, 2022

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 cdce8p mentioned this issue Nov 14, 2022
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

No branches or pull requests

3 participants