pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.24k stars 1.12k forks source link

False positive `deprecated-module` caused by name collision #4629

Closed akosthekiss closed 3 years ago

akosthekiss commented 3 years ago

Steps to reproduce

Given multiple files:

mypkg/
    formatter/
        __init__.py
    other/
        __init__.py
    __init__.py

Where:

"""mypkg/formatter/__init__.py"""

def fmtr():
    """fmtr()"""
"""mypkg/other/__init__.py"""

from ..formatter import fmtr
"""mypkg/__init__.py"""

from . import formatter
from .formatter import fmtr

Current behavior

Result of pylint mypkg:

************* Module mypkg
mypkg/__init__.py:4:0: W0402: Uses of a deprecated module 'formatter' (deprecated-module)
************* Module mypkg.other
mypkg/other/__init__.py:3:0: W0402: Uses of a deprecated module 'formatter' (deprecated-module)

Expected behavior

No deprecated-module diagnostics.

pylint --version output

Result of pylint --version output:

pylint 3.0.0-a4
astroid 2.6.1
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0]
pylint 2.9.0
astroid 2.6.1
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0]
Pierre-Sassoulas commented 3 years ago

@matusvalo do you have an idea how to fix this ? Can we use the absolute name to do the check ?

matusvalo commented 3 years ago

I suppose that yes. I will investigate.

matusvalo commented 3 years ago

Please assign this issue to me.

Pierre-Sassoulas commented 3 years ago

Thank you for handling this, much appreciated :)