Open skirpichev opened 1 year ago
Thank you for opening the issue, could you provide a code example and the expected result please ?
An example:
$ cat -n a.py
1 class Foo(type):
2 def __new__(cls):
3 return object()
$ pylint -s n a.py
************* Module a
a.py:1:0: C0114: Missing module docstring (missing-module-docstring)
a.py:1:0: C0115: Missing class docstring (missing-class-docstring)
a.py:2:4: C0204: Metaclass class method __new__ should have 'mcs' as first argument (bad-mcs-classmethod-argument)
No C0204 was expected, as the code conforms to the PEP 8.
I agree that all examples in this PR https://github.com/PyCQA/pylint/pull/7791/files are fine except for __new__
for which using cls
is correct as per pretty much the entire internet :)
On Wed, Feb 08, 2023 at 06:25:10AM -0800, Dani Alcala wrote:
I agree that all examples in this PR [1]https://github.com/PyCQA/pylint/pull/7791/files are fine except for new for which using cls is correct as per pretty much the entire internet :)
I'm not sure. PEP8 says: --->8--- Always use self for the first argument to instance methods.
Always use cls for the first argument to class methods. ------>8---
But for metaclasses in the stdlib I've seen mcls - for new (and for other classmethod's, I guess) cls - for instance methods.
See ABCMeta as an example.
Current problem
After #7791 we have the valid-metaclass-classmethod-first-arg checker with "mcs" default. While it does make sense for this checker, IMHO, the default set of checkers should conform to some popular style guide, most likely PEP8 (or to it's extension), but the new behaviour of the checker does violate PEP 8 (see also this).
Filled as a feature request, but I think it's a bug.
Desired solution
I'm suggesting to disable the checker per default or to revert #7791.
Additional context
No response