Skip to content

Calling abstract classmethod directly on the class #2926

@lolpack

Description

@lolpack

Calling an abstract @classmethod on the ABC class directly should be an error (no concrete implementation exists).

from abc import ABC, abstractmethod

class Factory(ABC):
    @classmethod
    @abstractmethod
    def create(cls) -> "Factory":
        raise NotImplementedError

Factory.create()

Sandbox: Pyrefly

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-discussionAn issue where it's not clear whether there is a bug or we are behaving as expected.typechecking
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions