---
source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs
---
ANN204 [*] Missing return type annotation for special method `__str__`
 --> simple_magic_methods.py:2:9
  |
1 | class Foo:
2 |     def __str__(self):
  |         ^^^^^^^
3 |         ...
  |
help: Add return type annotation: `str`
  |
1 | class Foo:
  -     def __str__(self):
2 +     def __str__(self) -> str:
3 |         ...
  |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__repr__`
 --> simple_magic_methods.py:5:9
  |
3 |         ...
4 |
5 |     def __repr__(self):
  |         ^^^^^^^^
6 |         ...
  |
help: Add return type annotation: `str`
  |
4 |
  -     def __repr__(self):
5 +     def __repr__(self) -> str:
6 |         ...
  |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__len__`
 --> simple_magic_methods.py:8:9
  |
6 |         ...
7 |
8 |     def __len__(self):
  |         ^^^^^^^
9 |         ...
  |
help: Add return type annotation: `int`
  |
7 |
  -     def __len__(self):
8 +     def __len__(self) -> int:
9 |         ...
  |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__length_hint__`
  --> simple_magic_methods.py:11:9
   |
 9 |         ...
10 |
11 |     def __length_hint__(self):
   |         ^^^^^^^^^^^^^^^
12 |         ...
   |
help: Add return type annotation: `int`
   |
10 |
   -     def __length_hint__(self):
11 +     def __length_hint__(self) -> int:
12 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__init__`
  --> simple_magic_methods.py:14:9
   |
12 |         ...
13 |
14 |     def __init__(self):
   |         ^^^^^^^^
15 |         ...
   |
help: Add return type annotation: `None`
   |
13 |
   -     def __init__(self):
14 +     def __init__(self) -> None:
15 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__del__`
  --> simple_magic_methods.py:17:9
   |
15 |         ...
16 |
17 |     def __del__(self):
   |         ^^^^^^^
18 |         ...
   |
help: Add return type annotation: `None`
   |
16 |
   -     def __del__(self):
17 +     def __del__(self) -> None:
18 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__bool__`
  --> simple_magic_methods.py:20:9
   |
18 |         ...
19 |
20 |     def __bool__(self):
   |         ^^^^^^^^
21 |         ...
   |
help: Add return type annotation: `bool`
   |
19 |
   -     def __bool__(self):
20 +     def __bool__(self) -> bool:
21 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__bytes__`
  --> simple_magic_methods.py:23:9
   |
21 |         ...
22 |
23 |     def __bytes__(self):
   |         ^^^^^^^^^
24 |         ...
   |
help: Add return type annotation: `bytes`
   |
22 |
   -     def __bytes__(self):
23 +     def __bytes__(self) -> bytes:
24 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__format__`
  --> simple_magic_methods.py:26:9
   |
24 |         ...
25 |
26 |     def __format__(self, format_spec):
   |         ^^^^^^^^^^
27 |         ...
   |
help: Add return type annotation: `str`
   |
25 |
   -     def __format__(self, format_spec):
26 +     def __format__(self, format_spec) -> str:
27 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__contains__`
  --> simple_magic_methods.py:29:9
   |
27 |         ...
28 |
29 |     def __contains__(self, item):
   |         ^^^^^^^^^^^^
30 |         ...
   |
help: Add return type annotation: `bool`
   |
28 |
   -     def __contains__(self, item):
29 +     def __contains__(self, item) -> bool:
30 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__complex__`
  --> simple_magic_methods.py:32:9
   |
30 |         ...
31 |
32 |     def __complex__(self):
   |         ^^^^^^^^^^^
33 |         ...
   |
help: Add return type annotation: `complex`
   |
31 |
   -     def __complex__(self):
32 +     def __complex__(self) -> complex:
33 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__int__`
  --> simple_magic_methods.py:35:9
   |
33 |         ...
34 |
35 |     def __int__(self):
   |         ^^^^^^^
36 |         ...
   |
help: Add return type annotation: `int`
   |
34 |
   -     def __int__(self):
35 +     def __int__(self) -> int:
36 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__float__`
  --> simple_magic_methods.py:38:9
   |
36 |         ...
37 |
38 |     def __float__(self):
   |         ^^^^^^^^^
39 |         ...
   |
help: Add return type annotation: `float`
   |
37 |
   -     def __float__(self):
38 +     def __float__(self) -> float:
39 |         ...
   |
note: This is an unsafe fix and may change runtime behavior

ANN204 [*] Missing return type annotation for special method `__index__`
  --> simple_magic_methods.py:41:9
   |
39 |         ...
40 |
41 |     def __index__(self):
   |         ^^^^^^^^^
42 |         ...
   |
help: Add return type annotation: `int`
   |
40 |
   -     def __index__(self):
41 +     def __index__(self) -> int:
42 |         ...
   |
note: This is an unsafe fix and may change runtime behavior
