Skip to content

classmethods should not be able to be called on abstract classes #14062

Description

@DetachHead
from abc import ABC, abstractmethod

class Foo(ABC):
    @classmethod
    def foo(cls) -> Foo:
        return cls()
    
    @abstractmethod
    def bar(self) -> None:
        ...

Foo.foo() # no error

playground

most of the time, classmethods are instantiating the class, so it should not allow you to call them on abstract classes.

i do however think staticmethods should still be allowed as they do not have access to the cls

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions