Skip to content

import-self only compares the name of a module and doesn't consider the actual module being imported #7289

Open
@vapier

Description

@vapier

Bug description

# This module is named "gzip".
#!/usr/bin/python3
"""Test"""
import gzip
gzip.main()

Configuration

No response

Command used

pylint gzip

Pylint output

************* Module gzip
gzip:5:0: W0406: Module import itself (import-self)
gzip:7:0: E1101: Module 'gzip' has no 'main' member (no-member)

Expected behavior

pylint shouldn't think a program named "foo" can be imported as "foo" when it doesn't have a .py extension

Pylint version

pylint 2.14.5
astroid 2.11.7
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]

OS / Environment

Linux

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeImport systemNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions