File tree 5 files changed +24
-16
lines changed
crates/red_knot_python_semantic/resources/mdtest
5 files changed +24
-16
lines changed Original file line number Diff line number Diff line change 1
1
# ` LiteralString `
2
2
3
- ``` toml
4
- [environment ]
5
- target-version = " 3.11"
6
- ```
7
-
8
3
` LiteralString ` represents a string that is either defined directly within the source code or is
9
4
made up of such components.
10
5
Original file line number Diff line number Diff line change 1
1
# NoReturn & Never
2
2
3
- ``` toml
4
- [environment ]
5
- target-version = " 3.11"
6
- ```
7
-
8
3
` NoReturn ` is used to annotate the return type for functions that never return. ` Never ` is the
9
4
bottom type, representing the empty set of Python objects. These two annotations can be used
10
5
interchangeably.
@@ -52,7 +47,7 @@ def f():
52
47
53
48
## ` typing.Never `
54
49
55
- ` typing.Never ` is only available in Python 3.11 and later:
50
+ ### Python 3.11
56
51
57
52
``` toml
58
53
[environment ]
@@ -61,9 +56,22 @@ target-version = "3.11"
61
56
62
57
``` py
63
58
from typing import Never
59
+ from typing import Never
64
60
65
- x: Never
61
+ reveal_type(Never) # revealed: typing.Never
62
+ ```
66
63
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
69
77
```
Original file line number Diff line number Diff line change 1
1
# Except star
2
2
3
+ ` except* ` is only available in Python 3.11 and later:
4
+
3
5
``` toml
4
6
[environment ]
5
7
target-version = " 3.11"
Original file line number Diff line number Diff line change @@ -101,14 +101,15 @@ else:
101
101
102
102
### Handling of ` None `
103
103
104
+ ` types.NoneType ` is only available in Python 3.10 and later:
105
+
104
106
``` toml
105
107
[environment ]
106
108
target-version = " 3.10"
107
109
```
108
110
109
111
``` 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.
112
113
# error: [possibly-unbound-import] "Member `NoneType` of module `types` is possibly unbound"
113
114
from types import NoneType
114
115
Original file line number Diff line number Diff line change 1
1
# Type aliases
2
2
3
+ Type aliases are only available in Python 3.12 and later:
4
+
3
5
``` toml
4
6
[environment ]
5
7
target-version = " 3.12"
You can’t perform that action at this time.
0 commit comments