[red-knot] Format mdtest Python snippets more concisely (#13905)

This commit is contained in:
Alex Waygood
2024-10-24 12:09:31 +01:00
committed by GitHub
parent 77ae0ccf0f
commit 3eb454699a
33 changed files with 4 additions and 193 deletions

View File

@@ -5,7 +5,6 @@
```py
class NotSubscriptable: ...
a = NotSubscriptable()[0] # error: "Cannot subscript object of type `NotSubscriptable` with no `__getitem__` method"
```
@@ -15,7 +14,6 @@ a = NotSubscriptable()[0] # error: "Cannot subscript object of type `NotSubscri
class NotSubscriptable:
__getitem__ = None
a = NotSubscriptable()[0] # error: "Method `__getitem__` of type `None` is not callable on object of type `NotSubscriptable`"
```
@@ -26,7 +24,6 @@ class Identity:
def __getitem__(self, index: int) -> int:
return index
reveal_type(Identity()[0]) # revealed: int
```
@@ -35,18 +32,15 @@ reveal_type(Identity()[0]) # revealed: int
```py
flag = True
class Identity:
if flag:
def __getitem__(self, index: int) -> int:
return index
else:
def __getitem__(self, index: int) -> str:
return str(index)
reveal_type(Identity()[0]) # revealed: int | str
```