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.27k stars 1.13k forks source link

Better explanation for reasoning behind ``invalid-name`` warnings #6053

Open Pierre-Sassoulas opened 2 years ago

Pierre-Sassoulas commented 2 years ago

Current problem

We're getting a lot of report for the new TypeVar naming style lately (#6050, #6003). It's probably annoying users. We took a decision but it's not conveyed in the warning message. We also have a long standing issue with snake_case requiring to be more than 3 letters and less than 30 characters long but not explaining it properly (the regex behind it is also hidden).

Desired solution

We could replace doesn't conform to predefined naming style by ``is not in snake_case and between 3 and 30 char long" by adding a description attribute to NameStyle. It's a lot easier to do than to actually refactor the checker to separate length and name style.

Additional context

2018

mwgamble commented 2 years ago

It would be great if the error messages could get more specific when necessary. For example, if a variable named ThingType is detected, it should explicitly tell the user that the Type suffix is forbidden.

bmitc commented 6 months ago

An improved error message would indeed be very helpful, especially since this is a bit contentious and a strict convention. I just hit upon this today, as it's quite natural to suffix with Type to distinguish it from a real type.