class astroid.nodes.ImportFrom(fromname: str | None, names: list[tuple[str, str | None]], level: int | None = 0, lineno: int | None = None, col_offset: int | None = None, parent: NodeNG | None = None, *, end_lineno: int | None = None, end_col_offset: int | None = None)[source]

Bases: ImportNode

Class representing an ast.ImportFrom node.

>>> import astroid
>>> node = astroid.extract_node('from my_package import my_module')
>>> node
<ImportFrom l.1 at 0x7f23b2e415c0>
level: int | None

The level of relative import.

Essentially this is the number of dots in the import. This is always 0 for absolute imports.

modname: str | None

The module that is being imported from.

This is None for relative imports.

names: list[tuple[str, str | None]]

What is being imported from the module.

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