Skip to content

Pylint does not follow python import order : Builtin modules are imported before custom modules  #6535

Open
pylint-dev/astroid
#2223
@electriquo

Description

Bug description

when a project holds a module name that shadows builtin module name, pylist fails on no-member, when clearly this is not the case.

reproduction

given 2 files:

  1. os.py an empty file
  2. test.py with the following content
    """test.py"""
    
    import os
    print(os.environ['SHELL'])

and now pylint fails on no-member as follows

$ pylint **/*.py
************* Module test
test.py:4:6: E1101: Module 'os' has no 'environ' member (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

but the code is correct

$ python test.py
/usr/local/bin/bash

Configuration

No response

Command used

pylint **/*.py

Pylint output

************* Module test
test.py:4:6: E1101: Module 'os' has no 'environ' member (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

pylint should be aware of the import tree, and report such issue if that is indeed the case.

in the reproduction snippet above, test.py imports the os builtin module (and not os.py) that has the environ().

Pylint version

pylint 2.13.8
astroid 2.11.4
Python 3.10.3 (main, Mar 17 2022, 09:46:58) [Clang 13.1.6 (clang-1316.0.21.2)]

OS / Environment

macos

$ sw_vers
ProductName:	macOS
ProductVersion:	12.3.1
BuildVersion:	21E258

Additional dependencies

No response

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 implementationNeeds astroid updateNeeds an astroid update (probably a release too) before being mergablepython 3.10

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions