-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
N804 disagrees with pylint on __new__ first argument's name for metaclass #10656
Comments
|
How did you differentiate code concerning metaclasses and classes ? pylint has https://pylint.readthedocs.io/en/stable/user_guide/messages/convention/bad-mcs-classmethod-argument.html (for metaclasses) but also https://pylint.readthedocs.io/en/stable/user_guide/messages/convention/bad-classmethod-argument.html (for classes). I think metaclasses methods are used way less frequently than class methods. |
@charliermarsh This is not accurate. In metaclasses, |
I Completely agree with @jnrbsn. I always interpreted a However, I should point out something I find very strange from PEP 3115: # The metaclass
class OrderedClass(type):
# The prepare function
@classmethod
def __prepare__(metacls, name, bases): # No keywords in this case
return member_table()
# The metaclass invocation
def __new__(cls, name, bases, classdict):
# Note that we replace the classdict with a regular
# dict before passing it to the superclass, so that we
# don't continue to record member names after the class
# has been created.
result = type.__new__(cls, name, bases, dict(classdict))
result.member_names = classdict.member_names
return result You can see that the author used different So in the end, I do think Python doc suggests the use of |
Here's an example:
To be fair I'm not sure if it's an issue with ruff or pylint, but they seem to both disagree on what to name the first argument of __new__ in a metaclass. Who's right ?
The text was updated successfully, but these errors were encountered: