---
source: crates/ty_test/src/lib.rs
expression: snapshot
---
---
mdtest name: invalid.md - Tests for invalid types in type expressions - Diagnostics for common errors - Tuple-literal used when you meant to use a tuple
mdtest path: crates/ty_python_semantic/resources/mdtest/annotations/invalid.md
---

# Python source files

## mdtest_snippet.py

```
 1 | def _(
 2 |     x: (),  # error: [invalid-type-form]
 3 | ) -> ():  # error: [invalid-type-form]
 4 |     return x
 5 | def _(
 6 |     x: (int,),  # error: [invalid-type-form]
 7 | ) -> (int,):  # error: [invalid-type-form]
 8 |     return x
 9 | def _(
10 |     x: (int, str),  # error: [invalid-type-form]
11 | ) -> (int, str):  # error: [invalid-type-form]
12 |     return x
```

# Diagnostics

```
error[invalid-type-form]: Tuple literals are not allowed in this context in a type expression
 --> src/mdtest_snippet.py:2:8
  |
1 | def _(
2 |     x: (),  # error: [invalid-type-form]
  |        ^^ Did you mean `tuple[()]`?
3 | ) -> ():  # error: [invalid-type-form]
4 |     return x
  |
info: See the following page for a reference on valid type expressions:
info: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions
info: rule `invalid-type-form` is enabled by default

```

```
error[invalid-type-form]: Tuple literals are not allowed in this context in a type expression
 --> src/mdtest_snippet.py:3:6
  |
1 | def _(
2 |     x: (),  # error: [invalid-type-form]
3 | ) -> ():  # error: [invalid-type-form]
  |      ^^ Did you mean `tuple[()]`?
4 |     return x
5 | def _(
  |
info: See the following page for a reference on valid type expressions:
info: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions
info: rule `invalid-type-form` is enabled by default

```

```
error[invalid-type-form]: Tuple literals are not allowed in this context in a type expression
 --> src/mdtest_snippet.py:6:8
  |
4 |     return x
5 | def _(
6 |     x: (int,),  # error: [invalid-type-form]
  |        ^^^^^^ Did you mean `tuple[int]`?
7 | ) -> (int,):  # error: [invalid-type-form]
8 |     return x
  |
info: See the following page for a reference on valid type expressions:
info: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions
info: rule `invalid-type-form` is enabled by default

```

```
error[invalid-type-form]: Tuple literals are not allowed in this context in a type expression
 --> src/mdtest_snippet.py:7:6
  |
5 | def _(
6 |     x: (int,),  # error: [invalid-type-form]
7 | ) -> (int,):  # error: [invalid-type-form]
  |      ^^^^^^ Did you mean `tuple[int]`?
8 |     return x
9 | def _(
  |
info: See the following page for a reference on valid type expressions:
info: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions
info: rule `invalid-type-form` is enabled by default

```

```
error[invalid-type-form]: Tuple literals are not allowed in this context in a type expression
  --> src/mdtest_snippet.py:10:8
   |
 8 |     return x
 9 | def _(
10 |     x: (int, str),  # error: [invalid-type-form]
   |        ^^^^^^^^^^ Did you mean `tuple[int, str]`?
11 | ) -> (int, str):  # error: [invalid-type-form]
12 |     return x
   |
info: See the following page for a reference on valid type expressions:
info: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions
info: rule `invalid-type-form` is enabled by default

```

```
error[invalid-type-form]: Tuple literals are not allowed in this context in a type expression
  --> src/mdtest_snippet.py:11:6
   |
 9 | def _(
10 |     x: (int, str),  # error: [invalid-type-form]
11 | ) -> (int, str):  # error: [invalid-type-form]
   |      ^^^^^^^^^^ Did you mean `tuple[int, str]`?
12 |     return x
   |
info: See the following page for a reference on valid type expressions:
info: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions
info: rule `invalid-type-form` is enabled by default

```
