pylint icon indicating copy to clipboard operation
pylint copied to clipboard

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

Open Pierre-Sassoulas opened this issue 3 years ago • 2 comments
trafficstars

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

Pierre-Sassoulas avatar Mar 30 '22 09:03 Pierre-Sassoulas

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.

mwgamble avatar Apr 19 '22 12:04 mwgamble

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.

bmitc avatar Apr 04 '24 00:04 bmitc