Description
Bug description
I am seeing an issue with a sometimes false positive when using two modules with the same name but one of them under separate namespace. The following is the directory structure and contents:
├── module
│ └── __init__.py
├── package1
│ └── module
│ └── __init__.py
└── test.py
$ cat module/__init__.py
def main():
pass
$ cat package1/module/__init__.py
def dummyfunc():
pass
$ cat test.py
"""Test module"""
import module
import package1.module
module.main()
Command run:
python3.12 -m pylint package1/module/ test.py
There seems to be some kind of module name conflict with module
happening and sometimes I see a no-member
error in the output even though the main
function is defined in module/__init__.py
test.py:5:0: E1101: Module 'module' has no 'main' member (no-member)
When taking a closer look and trying to debug this, at least the non-deterministic behavior seems to stem from https://github.com/pylint-dev/pylint/blob/main/pylint/lint/pylinter.py#L667 where the code is trying to convert a set of paths to a list.
### Configuration
```ini
No configuration used.
Command used
python3.12 -m pylint package1/module/ test.py
Pylint output
Depending on the run, I see different outputs (one is correct and the other is incorrect):
Output 1 (correct):
************* Module package1.module
package1/module/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
package1/module/__init__.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module test
test.py:3:0: W0611: Unused import package1.module (unused-import)
Output 2 (false no-member
error):
************* Module module
package1/module/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
package1/module/__init__.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module test
test.py:5:0: E1101: Module 'module' has no 'main' member (no-member)
test.py:3:0: W0611: Unused import package1.module (unused-import)
Expected behavior
************* Module package1.module
package1/module/init.py:1:0: C0114: Missing module docstring (missing-module-docstring)
package1/module/init.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module test
test.py:3:0: W0611: Unused import package1.module (unused-import)
Pylint version
pylint 3.2.6
astroid 3.2.4
Python 3.12.3 (v3.12.3:f6650f9ad7, Apr 9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)]
OS / Environment
Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112 arm64
I am also able to reproduce on Windows 10 WSL 2 (Ubuntu 22.04)
Additional dependencies
No response