Skip to content

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

Closed
@Julian

Description

@Julian

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions