Skip to content

False "import-self" when importing a package from stdlib with same name than local subpackage #3665

Closed
@niander

Description

@niander

I have a package named logging, which is inside a namespace package (python 3.0 style)

bar
├── logging
│   ├─ __init__.py

in __init__.py

from logging import DEBUG, INFO, WARN

Here, logging refers to the std library. But, pylint is giving W0406: import-self for the statement.

Steps to reproduce

  1. Run python -m pylint src/bar/logging/__init__.py

Current behavior

************* Module logging
src/bar/logging/__init__.py:3:0: W0406: Module import itself (import-self)
src/bar/logging/__init__.py:3:0: W0406: Module import itself (import-self)
src/bar/logging/__init__.py:3:0: W0406: Module import itself (import-self)

Expected behavior

No error because logging is not a reference to itself.

pylint --version output

pylint 2.4.4
astroid 2.3.3
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions