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

There's unfortunately a legitimate use of @staticmethod #12

Closed
Julian opened this issue Sep 6, 2018 · 2 comments
Closed

There's unfortunately a legitimate use of @staticmethod #12

Julian opened this issue Sep 6, 2018 · 2 comments

Comments

@Julian
Copy link
Member

Julian commented Sep 6, 2018

[This might be a duplicate of #7, in that it's wrong 99.9% of the time so maybe we say "that's close enough" and make anyone with a legitimate use have to use noqa once that works. In fact that'd probably be what I'd lean towards, but filing this in case it's worth discussing]

There's, I've realized, one legitimate use for @staticmethod --

If you have a module with a (normal, non-descriptor) object, and you want to replace that object with a normal function instead, the function you use likely always, but at least sometimes, should be @staticmethoded if you think that the previous object might have been being used as a class attribute by end-user code.

If you don't, when you change to a function, end-user code will break as their object suddenly becomes a descriptor and has its calling arguments changed.

@Julian
Copy link
Member Author

Julian commented Dec 15, 2018

OK echo chamber -- so, I think an actual good modification here might be "@staticmethod is always wrong within class bodies".

@Julian
Copy link
Member Author

Julian commented Dec 16, 2018

Except because @staticmethod sucks so bad, I forgot that staticmethods aren't callable. So, never mind all this, and everything is terrible.

@Julian Julian closed this as completed Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant