Skip to content

Commit 4bd513d

Browse files
committed
Explain version bounds in tests
1 parent 4112ad4 commit 4bd513d

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

crates/red_knot_python_semantic/resources/mdtest/annotations/literal_string.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# `LiteralString`
22

3-
```toml
4-
[environment]
5-
target-version = "3.11"
6-
```
7-
83
`LiteralString` represents a string that is either defined directly within the source code or is
94
made up of such components.
105

crates/red_knot_python_semantic/resources/mdtest/annotations/never.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# NoReturn & Never
22

3-
```toml
4-
[environment]
5-
target-version = "3.11"
6-
```
7-
83
`NoReturn` is used to annotate the return type for functions that never return. `Never` is the
94
bottom type, representing the empty set of Python objects. These two annotations can be used
105
interchangeably.
@@ -52,7 +47,9 @@ def f():
5247

5348
## `typing.Never`
5449

55-
`typing.Never` is only available in Python 3.11 and later:
50+
`typing.Never` is only available in Python 3.11 and later.
51+
52+
### Python 3.11
5653

5754
```toml
5855
[environment]
@@ -62,8 +59,20 @@ target-version = "3.11"
6259
```py
6360
from typing import Never
6461

65-
x: Never
62+
reveal_type(Never) # revealed: typing.Never
63+
```
6664

67-
def f():
68-
reveal_type(x) # revealed: Never
65+
### Python 3.10
66+
67+
```toml
68+
[environment]
69+
target-version = "3.10"
70+
```
71+
72+
```py
73+
# TODO: should raise a diagnostic
74+
from typing import Never
75+
76+
# TODO: this should be Unknown
77+
reveal_type(Never) # revealed: Never
6978
```

crates/red_knot_python_semantic/resources/mdtest/exception/except_star.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Except star
22

3+
`except*` is only available in Python 3.11 and later:
4+
35
```toml
46
[environment]
57
target-version = "3.11"

crates/red_knot_python_semantic/resources/mdtest/narrow/issubclass.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ else:
101101

102102
### Handling of `None`
103103

104+
`types.NoneType` is only available in Python 3.10 and later:
105+
104106
```toml
105107
[environment]
106108
target-version = "3.10"
107109
```
108110

109111
```py
110-
# TODO: this error should ideally go away once we (1) understand `sys.version_info` branches,
111-
# and (2) set the target Python version for this test to 3.10.
112+
# TODO: this error should ideally go away once we understand `sys.version_info` branches.
112113
# error: [possibly-unbound-import] "Member `NoneType` of module `types` is possibly unbound"
113114
from types import NoneType
114115

crates/red_knot_python_semantic/resources/mdtest/type_alias.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Type aliases
22

3+
Type aliases are only available in Python 3.12 and later:
4+
35
```toml
46
[environment]
57
target-version = "3.12"

0 commit comments

Comments
 (0)