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.31k stars 1.14k forks source link

`invalid-name` and `arguments-renamed` not triggered by constructor arguments in derived class #8986

Open dagardner-nv opened 1 year ago

dagardner-nv commented 1 year ago

Bug description

When a derived class has naming errors for a constructor argument the invalid-name and arguments-renamed messages are not reported.

Ex:

# pylint: disable=too-few-public-methods, missing-docstring

class Base:
    def __init__(self, config):
        print("Base.__init__")
        self.config = config

class Derived(Base):
    # This should trigger invalid-name and arguments-renamed
    def __init__(self, c):
        super().__init__(c)
        print("Derived.__init__")

Configuration

No response

Command used

pylint -v repro.py

Pylint output

No config file found, using default configuration

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

Expected behavior

The c argument in the constructor for Derived on line 11 should trigger both invalid-name and arguments-renamed messages.

Pylint version

pylint 2.17.5
astroid 2.15.6
Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]

OS / Environment

Debian 11.7 Conda

Additional dependencies

astroid @ file:///home/conda/feedstock_root/build_artifacts/astroid_1688921184010/work colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work dill @ file:///home/conda/feedstock_root/build_artifacts/dill_1690101045195/work isort @ file:///home/conda/feedstock_root/build_artifacts/isort_1675033873689/work lazy-object-proxy @ file:///home/conda/feedstock_root/build_artifacts/lazy-object-proxy_1672877787898/work mccabe @ file:///home/conda/feedstock_root/build_artifacts/mccabe_1643049622439/work platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1690813113769/work pylint @ file:///home/conda/feedstock_root/build_artifacts/pylint_1690375221593/work tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1644342247877/work tomlkit @ file:///home/conda/feedstock_root/build_artifacts/tomlkit_1690472772788/work typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1688315532570/work wrapt @ file:///home/conda/feedstock_root/build_artifacts/wrapt_1677485519705/work

dagardner-nv commented 1 year ago

If I try and reproduce this with a method other than the constructor, I get the arguments-renamed message bit not the invalid-name message:

# pylint: disable=too-few-public-methods, missing-docstring

class Base:
    def __init__(self, config):
        print("Base.__init__")
        self.config = config

    def print_config(self, verbose=False):
        print(self.config)
        if verbose:
            print("Verbose mode is on")

class Derived(Base):
    def print_config(self, v=False):
        super().print_config(verbose=v)
        print("Derived.print_config")
$ pylint -v repro3.py 
No config file found, using default configuration
************* Module repro3
repro3.py:14:4: W0237: Parameter 'verbose' has been renamed to 'v' in overriding 'Derived.print_config' method (arguments-renamed)

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