Description
Current problem
I thought it would be nice to have a checker that detects magic numbers (aka. unnamed constants) in Pylint
.
As in all standard languages, -1
, 0
and 1
are allowed by default. Other numbers should raise a message unless would be specified in the pylintrc
file.
As not all might want to use it and since it is just really a bad practice and never an error it should be considered as an extension instead of core checker.
According to my test there is nothing like that in Pylint
, but I'd like to be proven wrong :)
Example:
seconds = 60
func(a, b, 50)
shows no error related to magic number
Desired solution
1: seconds = 60
2: func(a, b, 50)
should show 2 messages of type Refactor
(it is never an error just a bad practice in my opinion).
1: "Unnamed constant '60' is used, consider using literal instead of magic numbers."
2: "Unnamed constant '50' is used, consider using literal instead of magic numbers."
Additional context
Similar issue was opened but it was a bit different and more complicated than what I suggest here, see #1379