[red-knot] Autoformat mdtest Python snippets using blacken-docs (#13809)

This commit is contained in:
Alex Waygood
2024-10-19 15:57:06 +01:00
committed by GitHub
parent 2ff36530c3
commit 36cb1199cc
45 changed files with 331 additions and 132 deletions

View File

@@ -3,7 +3,9 @@
## Getitem unbound
```py
class NotSubscriptable: pass
class NotSubscriptable: ...
a = NotSubscriptable()[0] # error: "Cannot subscript object of type `NotSubscriptable` with no `__getitem__` method"
```
@@ -13,6 +15,7 @@ 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`"
```
@@ -23,6 +26,7 @@ class Identity:
def __getitem__(self, index: int) -> int:
return index
reveal_type(Identity()[0]) # revealed: int
```
@@ -31,13 +35,18 @@ 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
```