Description
Bug description
With #7411 by @DanielNoord # pylint: disable-next=
only considers lint errors of next line as ignored (in order to fix #7401)
So this is the Regression Issue that @Pierre-Sassoulas already saw comming ;-)
The problem a bit more in detail:
Before this PR it was easy to ignore errors of bigger functions definition, i.e.
@validator("sender_mail", always=True, pre=True)
# pylint: disable-next=no-self-use, no-self-argument, unused-argument
def set_email_if_possible(
cls, value: Any, values: dict[str, Any], extra_information_place_holder: dict[str, Any]
) -> Optional[NameEmail]:
try:
return split_name_and_mail(values.get("sender_from", ""))
except ValueError:
return None
and the usage was quite clear to me.
Now it behaves more like a disable-for-next-line
and not like a disable the next occurrence of
, which the name suggests to me and co-workers.
This behaviour was a blessing especially using black
.
Black brakes too long lines, so if you add a disable line that is too long (at least it did in the past).
This makes it hard to find a working combination things that is not braking black and pylint.
So with this MR/the new version I have start all over again, trying to get stuff to work with black:
@validator("sender_mail", always=True, pre=True)
# pylint: disable-next=no-self-argument, unused-argument
def set_email_if_possible(
# pylint: disable-next=unused-argument
cls, value: Any, values: dict[str, Any], extra_information_place_holder: dict[str, Any]
) -> Optional[NameEmail]:
try:
return split_name_and_mail(values.get("sender_from", ""))
except ValueError:
return None
The unused argument are value
and extra_information_place_holder
.
Now adding some more typing information will cause black to write each variable on a new line.
So I have to adopt the ignore line again and worse duplicate it.
Configuration
not relevant
Command used
pylint file.py
Pylint output
Displays the error that was ignored before the merge of #7411
Expected behavior
Restore the old behaviour of ignoring the next occurrence of the defined errors.
Or at least consider the context of the next line.
So I write # pylint: disable-next=
before a function, I would think that all error of the function definition are ignored, i.e. unused-argument
.
And I also would assume that all errors, that exist in the context of a function, i.e. too-many-locals
are also ignored within the function.
To give a bit more background:
The # pylint: disable-next
feature was one of the reasons we could convince people to use black company wide (pylint was already activated company wide).
Before it was really a pain, when black reformatted stuff causing pylint to fail.
Adding block of # pylint: disable
#pylint: enable
were error prone and ugly.
Pylint version
pylint 2.15.3
astroid 2.12.10
Python 3.10.6 | company distribution | (main, Sep 29 2022, 13:58:30) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)]
OS / Environment
No response
Additional dependencies
No response