[ty] __class_getitem__ is a classmethod (#20192)

## Summary

`__class_getitem__` is [implicitly a
classmethod](https://docs.python.org/3/reference/datamodel.html#object.__class_getitem__).

## Test Plan

Added regression test.
This commit is contained in:
David Peter
2025-09-01 11:22:19 +02:00
committed by GitHub
parent 5518c84ab3
commit bbfcf6e111
3 changed files with 11 additions and 2 deletions

View File

@@ -19,6 +19,12 @@ class Identity:
reveal_type(Identity[0]) # revealed: str
```
`__class_getitem__` is implicitly a classmethod, so it can be called like this:
```py
reveal_type(Identity.__class_getitem__(0)) # revealed: str
```
## Class getitem union
```py