pylint-dev/pylint

false negative "too-many-arguments"

buhtz opened this issue · 5 comments

Bug description

Original Code: https://codeberg.org/buhtz/buhtzology/src/commit/65f71ca1b5621fa3e3400ec0bcdd5de84ec206db/src/buhtzology/stausberg.py#L141-L149

Expect "too-many-arguments" because here are 6 instead of 5 arguments. But pylint do not detect that.


def weight_by_icd_group(data: pandas.DataFrame,
                        index_column: str,
                        icd_column: str,
                        weight_name: str = 'weight',
                        ignored_icds: tuple = ('UUU'),
                        exclude_appendix_artifact: bool = True
                        ) -> pandas.DataFrame:
    pass


### Configuration

```ini
no config

Command used

pylint src.py

Pylint output

No output because no error.

Expected behavior

too-many-arguments error

Pylint version

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

OS / Environment

Debian 11

Additional dependencies

No response

Hey @buhtz it looks like expected behaviour because one of the parameter names begins with the string ignored_.
That parameter is excluded from the count of total parameters.

Technically I do understand. But what is the reason behind it? How does this improve code quality?

The reason is that the default value for the --ignored-argument-names setting includes ignored, which you are using in your snippet. That's unlucky in your case, but it has a fix -- you can set --ignored-argument-names to something else if you have a legitimate use case for an argument name that begins with that word.

I am still not convinced but I would minimally treat this as a bug in documentation. The docu page about that error/rule should mention the exceptional cases caused by ignoored-argument-names.

This would be greatly alleviated by #9184