Skip to content
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

(🎁) should N804 enforce mcs on metaclass classmethods? #13698

Open
KotlinIsland opened this issue Oct 10, 2024 · 4 comments
Open

(🎁) should N804 enforce mcs on metaclass classmethods? #13698

KotlinIsland opened this issue Oct 10, 2024 · 4 comments
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule

Comments

@KotlinIsland
Copy link
Contributor

class M(type):
   def f(self):  # N804
       pass
   def m(cls):  # no error
       pass
   @classmethod
   def m(cls):  # no error
       pass
    @classmethod
    def c(mcs):  # N804
       pass

i would expect this to be N804, no error, N804, no error

@dhruvmanila
Copy link
Member

There does seem to be some precedent for the "mcs" shorthand: https://grep.app/search?q=def%20%5B%5E(%5D+%5C(mcs%5B,%5C)%5D&regexp=true, @AlexWaygood any thoughts?

@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Oct 10, 2024
@eliegoudout
Copy link

eliegoudout commented Dec 21, 2024

Even though mcs itself maybe not be widely accepted, the fact that that it should be a one of mcs, mcls, metacls, <any other possible shorthand> to explicit difference in nature from cls (instance space in the case of metaclasses) seems more than reasonable (see #10656 (comment)).

I would love to see #13698 (comment) (planned to be) fixed!

Personnal opinion: I really love mcs for 3 reasons:

  1. Three characters, like cls.
  2. Hard to accidentally go from mcs to cls (or vice versa) than from mcls to cls.
  3. Precedent point + no "tall letter" (e.g. the l from cls) also makes it easier to "read the difference" from a quick glance imo.

@eliegoudout
Copy link

@MichaReiser
Copy link
Member

Related discussion about changing the rule not to enforce any naming convention for metaclass methods #6017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

4 participants