`foo = classmethod(foo)` does not create a working classmethod
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
```python
class Holder:
def foo(cls, string) -> int:
return len(string)
foo = classmethod(foo)
print(Holder.foo("hello"))
```
This "old-school" way of creating a classmethod fails to actually create a working classmethod, because then there is an error at the usage site:
```
ERROR sandbox.py:7:17-26: Argument `type[Holder]` is not assignable to parameter `cls` with type `Holder` in function `Holder.foo` [bad-argument-type]
```
To be fair, this seems to be already known as per this added test:
https://github.com/facebook/pyrefly/commit/13312a0a5c3938a39269f0784b9e77d71931c829#diff-26c448fa0342a86d400e514b164a5762e4b076068dc6d8a076c46411a58d7d92
Also to be fair, Pyright and Mypy don't seem to handle this either.
But as I ran into these usages, I thought I'd report this anyway.
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxlKnHAAQASuUmMATogDrr1-1sw9MLlwAKanAA09OABd2EdAHMAlPQC0APnpK53XvyPsYcgK7tesdGPmKVqnjyMjc9ALz1qtOAFtTABa4mGKujug8xPZyYsysHISuYlwgATBQULgpqqogUiBkJmBQpIRyuL5QFADE9AAKpEUlshg4BF646JDKFqhyEJ2EPLUAyjAw9AFycsRwiAD084UwxaW47MrzMOjzmLiUcPOUnd29-Z3zwuv0qABuqNCo2LAdXRA97H0DvLjE5%2BhwIboMhyILoDS3Dhwb4eegpADMhAAjAAmFI8ADaHHY6zgAF0eGZ0BBfMR1nIYJgNJgICZKP1IbCAOTvdDrGBMnhsuQaEwARzMtMpGgA1jBSBpUJRKPAGJ4mQB3VCWTnoEAAX3yUoZMAAYtAYBQ0Fg8EQyBqgA
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.