---
source: crates/red_knot_test/src/lib.rs
expression: snapshot
---
---
mdtest name: return_type.md - Function return type - Invalid return type in stub file
mdtest path: crates/red_knot_python_semantic/resources/mdtest/function/return_type.md
---

# Python source files

## mdtest_snippet.pyi

```
 1 | def f() -> int:
 2 |     # error: [invalid-return-type]
 3 |     return ...
 4 | 
 5 | # error: [invalid-return-type]
 6 | def foo() -> int:
 7 |     print("...")
 8 |     ...
 9 | 
10 | # error: [invalid-return-type]
11 | def foo() -> int:
12 |     f"""{foo} is a function that ..."""
13 |     ...
```

# Diagnostics

```
error: lint:invalid-return-type
 --> /src/mdtest_snippet.pyi:3:12
  |
1 | def f() -> int:
2 |     # error: [invalid-return-type]
3 |     return ...
  |            ^^^ Object of type `ellipsis` is not assignable to return type `int`
4 |
5 | # error: [invalid-return-type]
  |
info
 --> /src/mdtest_snippet.pyi:1:12
  |
1 | def f() -> int:
  |            --- Return type is declared here as `int`
2 |     # error: [invalid-return-type]
3 |     return ...
  |

```

```
error: lint:invalid-return-type
 --> /src/mdtest_snippet.pyi:6:14
  |
5 | # error: [invalid-return-type]
6 | def foo() -> int:
  |              ^^^ Function can implicitly return `None`, which is not assignable to return type `int`
7 |     print("...")
8 |     ...
  |

```

```
error: lint:invalid-return-type
  --> /src/mdtest_snippet.pyi:11:14
   |
10 | # error: [invalid-return-type]
11 | def foo() -> int:
   |              ^^^ Function can implicitly return `None`, which is not assignable to return type `int`
12 |     f"""{foo} is a function that ..."""
13 |     ...
   |

```
