Skip to content

Bug: incorrect docstring on ImportFrom.level #2571

Open
@epenet

Description

@epenet

According to the docstring the level of a relative import is 0 for absolute imports.
However, in practise it is actually None.

See:

# TODO When is 'level' None?
self.level: int | None = level # can be None
"""The level of relative import.
Essentially this is the number of dots in the import.
This is always 0 for absolute imports.
"""

I would suggest that the TODO is removed and that the docstring is ajusted accordingly.

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

3.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions