Skip to content

Commit 4ae7a5b

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

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

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

-5
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

+17-9
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,7 @@ def f():
5247

5348
## `typing.Never`
5449

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

5752
```toml
5853
[environment]
@@ -61,9 +56,22 @@ target-version = "3.11"
6156

6257
```py
6358
from typing import Never
59+
from typing import Never
6460

65-
x: Never
61+
reveal_type(Never) # revealed: typing.Never
62+
```
6663

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

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

+2
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

+3-2
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

+2
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)