Skip to content

Commit

Permalink
Explain version bounds in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Dec 6, 2024
1 parent 4112ad4 commit 4bd513d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# `LiteralString`

```toml
[environment]
target-version = "3.11"
```

`LiteralString` represents a string that is either defined directly within the source code or is
made up of such components.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# NoReturn & Never

```toml
[environment]
target-version = "3.11"
```

`NoReturn` is used to annotate the return type for functions that never return. `Never` is the
bottom type, representing the empty set of Python objects. These two annotations can be used
interchangeably.
Expand Down Expand Up @@ -52,7 +47,9 @@ def f():

## `typing.Never`

`typing.Never` is only available in Python 3.11 and later:
`typing.Never` is only available in Python 3.11 and later.

### Python 3.11

```toml
[environment]
Expand All @@ -62,8 +59,20 @@ target-version = "3.11"
```py
from typing import Never

x: Never
reveal_type(Never) # revealed: typing.Never
```

def f():
reveal_type(x) # revealed: Never
### Python 3.10

```toml
[environment]
target-version = "3.10"
```

```py
# TODO: should raise a diagnostic
from typing import Never

# TODO: this should be Unknown
reveal_type(Never) # revealed: Never
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Except star

`except*` is only available in Python 3.11 and later:

```toml
[environment]
target-version = "3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ else:

### Handling of `None`

`types.NoneType` is only available in Python 3.10 and later:

```toml
[environment]
target-version = "3.10"
```

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Type aliases

Type aliases are only available in Python 3.12 and later:

```toml
[environment]
target-version = "3.12"
Expand Down

0 comments on commit 4bd513d

Please sign in to comment.