facebook / facebook/pyrefly

Calling abstract classmethod directly on the class

Open
#2,926 1 comment 0 reactions 0 assignees View on GitHub
needs-discussion typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

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

```python
from abc import ABC, abstractmethod

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

Factory.create()
```

**Sandbox:** [Pyrefly](https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXAAlHAhgOwCYCMD2AHgHQAOAnksuAE74C2y6uAxshPafjQC7ICCAIQDCAGia44PGuhY96MHgAt82ADqYNLKOjhxkAMVk9u5ABRDhASkQbk95AAFtuuAuWq7Dx8yky57irqmA7I2DBgyCw0MOg8MGbacFbIALQAfMhqIEZyptm2IaEOMhBwMMgAcvg8AJKcsAqY8dgAojR0NBoauSY05MTRsfFmVhogAL7iIMYQAG4wBtAwVCAYOAQkFJNAA)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.