Preliminary support for class decorators
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
Minimal repro:
```python
class ActorHandle[T]:
"""Wrapper returned by the @remote decorator."""
def remote(self) -> T: ...
def options(self, num_cpus: int) -> "ActorHandle[T]": ...
def remote[T](cls: type[T]) -> ActorHandle[T]:
"""Decorator that replaces a class with an ActorHandle wrapper."""
return ActorHandle()
@remote
class Worker:
def compute(self) -> int:
return 42
# After decoration, Worker is ActorHandle[Worker], so .remote() is valid
Worker.remote() # pyrefly: Class `Worker` has no class attribute `remote`
Worker.options(num_cpus=2) # pyrefly: Class `Worker` has no class attribute `options`
```
Today only Pyright actually accepts this kind of code. So low-pri.
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxlKnHAAQCClALrgE4ASGmsA2gBUAuogA66epPqiQMmQHV2qYsRjt67GCwCu7dDEz1speiwAWMegAFNAW1wtLmGJQ6o27QnNmyJU52AaMPaOABRwMFBgAJT0ALQAfPQCiPSE6eJS9AH0uMQsELjocOGRYAA09OjatgD6lMTacKkQ6CyxidIgzB7cWPzCMqnpXujiOXYOMIJCodTNpqSqMx1JPRx9vNPCYn6S3jIAIi5uHqZm7kHENJTw9Kj01LQMAO4Q5vcS61w8sPQvShUai8PjkeyCOj0TFYG1%2BMFC0XE4hswSm4iedHo8g4AGs1LssjlXLZGmEIlFVvRWiwCVkpJpIRIACwAJiR6AAxEwwI51M5XEoCkVKtj2Hj1BAGN9NvxReKhJU4Lg0pMwrFJfQAG6oKAQTDiOXA1Xw2L0LlkTRgKCkVIAYRomIABob2I76BcGOhlRiGO4WOwINhtI56I7jY6DbjgXkhcVQtU6g0mgBeFmm82kS3Wu0OhjOqOu920Kre3P3Fj%2BwPByyOmOFYqOkDlEDB6BwEjkRAgLkAVQKupYJjA2nQrHrcHZOTAHFs7lqCewalC%2BBabUpcH9tMkDN0EjAMgAcjVF%2BxUsB8ABfMFNkAWmBW0iENi2KAULkABUz9%2Bt9DQWDw%2BCPEUkAAOa6O49ajFyADKMCWGYFbEM0AD0yF3g%2BhAcCByEwOgyGYLglBwMhrjoKB4Gxsh9DTuoqDatAqDYH8pHkYK9a5Pk46jGQ5hFHEmpqHA7HJl0ADMhAAIxsr4IAXs2qBjgJABi0AwBQf44AQHayUAA
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.