Why does pylint give this warning?
Peter Otten
__peter__ at web.de
Sun Jan 14 17:11:35 EST 2018
breamoreboy at gmail.com wrote:
> Why does pylint give this warning?
No idea.
> The warning is 'C0103:Method name "__len__" doesn't conform to
> '_?_?[a-z][A-Za-z0-9]{1,30}$' pattern' but it doesn't complain about
> __repr__ or __str__. If there is an explanation out in the wild my search
> fu has missed it :-(
>
> My setup on Ubuntu 17.10 is:-
>
> $ pylint --version
> Using config file /home/mark/.pylintrc
> pylint 1.8.1,
> astroid 1.6.0
> Python 3.6.3 (default, Oct 3 2017, 21:45:48)
> [GCC 7.2.0]
>
> --
> Kindest regards.
>
> Mark Lawrence.
I cannot replicate this with
$ pylint --version
Using config file /home/petto/.pylintrc
pylint 1.8.1,
astroid 1.6.0
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2]
$ cat pylint_fodder.py
class FooBar:
def __len__(self):
return 42
def __repr__(self):
return "FooBar(length={})".format(len(self))
$ pylint pylint_fodder.py
Using config file /home/petto/.pylintrc
************* Module pylint_fodder
C: 1, 0: Missing module docstring (missing-docstring)
C: 1, 0: Missing class docstring (missing-docstring)
R: 1, 0: Too few public methods (0/2) (too-few-public-methods)
-----------------------------------
Your code has been rated at 4.00/10
$
so the complaint is probably caused by your configuration file.
Rename it, regenerate the default with
$ pylint --generate-rcfile > ~/.pylintrc
and reapply your changes -- I hope there aren't too many of them ;) -- until
you see the warning message again.
More information about the Python-list
mailing list