---
source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs
---
annotation_presence.py:5:5: ANN201 [*] Missing return type annotation for public function `foo`
  |
4 | # Error
5 | def foo(a, b):
  |     ^^^ ANN201
6 |     pass
  |
  = help: Add return type annotation: `None`

ℹ Unsafe fix
2 2 | from typing_extensions import override
3 3 | 
4 4 | # Error
5   |-def foo(a, b):
  5 |+def foo(a, b) -> None:
6 6 |     pass
7 7 | 
8 8 | 

annotation_presence.py:5:9: ANN001 Missing type annotation for function argument `a`
  |
4 | # Error
5 | def foo(a, b):
  |         ^ ANN001
6 |     pass
  |

annotation_presence.py:5:12: ANN001 Missing type annotation for function argument `b`
  |
4 | # Error
5 | def foo(a, b):
  |            ^ ANN001
6 |     pass
  |

annotation_presence.py:10:5: ANN201 [*] Missing return type annotation for public function `foo`
   |
 9 | # Error
10 | def foo(a: int, b):
   |     ^^^ ANN201
11 |     pass
   |
   = help: Add return type annotation: `None`

ℹ Unsafe fix
7  7  | 
8  8  | 
9  9  | # Error
10    |-def foo(a: int, b):
   10 |+def foo(a: int, b) -> None:
11 11 |     pass
12 12 | 
13 13 | 

annotation_presence.py:10:17: ANN001 Missing type annotation for function argument `b`
   |
 9 | # Error
10 | def foo(a: int, b):
   |                 ^ ANN001
11 |     pass
   |

annotation_presence.py:15:17: ANN001 Missing type annotation for function argument `b`
   |
14 | # Error
15 | def foo(a: int, b) -> int:
   |                 ^ ANN001
16 |     pass
   |

annotation_presence.py:20:5: ANN201 [*] Missing return type annotation for public function `foo`
   |
19 | # Error
20 | def foo(a: int, b: int):
   |     ^^^ ANN201
21 |     pass
   |
   = help: Add return type annotation: `None`

ℹ Unsafe fix
17 17 | 
18 18 | 
19 19 | # Error
20    |-def foo(a: int, b: int):
   20 |+def foo(a: int, b: int) -> None:
21 21 |     pass
22 22 | 
23 23 | 

annotation_presence.py:25:5: ANN201 [*] Missing return type annotation for public function `foo`
   |
24 | # Error
25 | def foo():
   |     ^^^ ANN201
26 |     pass
   |
   = help: Add return type annotation: `None`

ℹ Unsafe fix
22 22 | 
23 23 | 
24 24 | # Error
25    |-def foo():
   25 |+def foo() -> None:
26 26 |     pass
27 27 | 
28 28 | 

annotation_presence.py:45:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
   |
44 | # ANN401
45 | def foo(a: Any, *args: str, **kwargs: str) -> int:
   |            ^^^ ANN401
46 |     pass
   |

annotation_presence.py:50:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo`
   |
49 | # ANN401
50 | def foo(a: int, *args: str, **kwargs: str) -> Any:
   |                                               ^^^ ANN401
51 |     pass
   |

annotation_presence.py:55:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args`
   |
54 | # ANN401
55 | def foo(a: int, *args: Any, **kwargs: Any) -> int:
   |                        ^^^ ANN401
56 |     pass
   |

annotation_presence.py:55:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`
   |
54 | # ANN401
55 | def foo(a: int, *args: Any, **kwargs: Any) -> int:
   |                                       ^^^ ANN401
56 |     pass
   |

annotation_presence.py:60:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args`
   |
59 | # ANN401
60 | def foo(a: int, *args: Any, **kwargs: str) -> int:
   |                        ^^^ ANN401
61 |     pass
   |

annotation_presence.py:65:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`
   |
64 | # ANN401
65 | def foo(a: int, *args: str, **kwargs: Any) -> int:
   |                                       ^^^ ANN401
66 |     pass
   |

annotation_presence.py:75:13: ANN101 Missing type annotation for `self` in method
   |
74 |     # ANN101
75 |     def foo(self, a: int, b: int) -> int:
   |             ^^^^ ANN101
76 |         pass
   |

annotation_presence.py:79:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
   |
78 |     # ANN401
79 |     def foo(self: "Foo", a: Any, *params: str, **options: str) -> int:
   |                             ^^^ ANN401
80 |         pass
   |

annotation_presence.py:83:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo`
   |
82 |     # ANN401
83 |     def foo(self: "Foo", a: int, *params: str, **options: str) -> Any:
   |                                                                   ^^^ ANN401
84 |         pass
   |

annotation_presence.py:87:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params`
   |
86 |     # ANN401
87 |     def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int:
   |                                           ^^^ ANN401
88 |         pass
   |

annotation_presence.py:87:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options`
   |
86 |     # ANN401
87 |     def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int:
   |                                                           ^^^ ANN401
88 |         pass
   |

annotation_presence.py:91:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params`
   |
90 |     # ANN401
91 |     def foo(self: "Foo", a: int, *params: Any, **options: str) -> int:
   |                                           ^^^ ANN401
92 |         pass
   |

annotation_presence.py:95:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options`
   |
94 |     # ANN401
95 |     def foo(self: "Foo", a: int, *params: str, **options: Any) -> int:
   |                                                           ^^^ ANN401
96 |         pass
   |

annotation_presence.py:130:13: ANN102 Missing type annotation for `cls` in classmethod
    |
128 |     # ANN102
129 |     @classmethod
130 |     def foo(cls, a: int, b: int) -> int:
    |             ^^^ ANN102
131 |         pass
    |

annotation_presence.py:134:13: ANN101 Missing type annotation for `self` in method
    |
133 |     # ANN101
134 |     def foo(self, /, a: int, b: int) -> int:
    |             ^^^^ ANN101
135 |         pass
    |

annotation_presence.py:149:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
    |
148 | # ANN401
149 | def f(a: Any | int) -> None: ...
    |          ^^^^^^^^^ ANN401
150 | def f(a: int | Any) -> None: ...
151 | def f(a: Union[str, bytes, Any]) -> None: ...
    |

annotation_presence.py:150:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
    |
148 | # ANN401
149 | def f(a: Any | int) -> None: ...
150 | def f(a: int | Any) -> None: ...
    |          ^^^^^^^^^ ANN401
151 | def f(a: Union[str, bytes, Any]) -> None: ...
152 | def f(a: Optional[Any]) -> None: ...
    |

annotation_presence.py:151:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
    |
149 | def f(a: Any | int) -> None: ...
150 | def f(a: int | Any) -> None: ...
151 | def f(a: Union[str, bytes, Any]) -> None: ...
    |          ^^^^^^^^^^^^^^^^^^^^^^ ANN401
152 | def f(a: Optional[Any]) -> None: ...
153 | def f(a: Annotated[Any, ...]) -> None: ...
    |

annotation_presence.py:152:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
    |
150 | def f(a: int | Any) -> None: ...
151 | def f(a: Union[str, bytes, Any]) -> None: ...
152 | def f(a: Optional[Any]) -> None: ...
    |          ^^^^^^^^^^^^^ ANN401
153 | def f(a: Annotated[Any, ...]) -> None: ...
154 | def f(a: "Union[str, bytes, Any]") -> None: ...
    |

annotation_presence.py:153:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
    |
151 | def f(a: Union[str, bytes, Any]) -> None: ...
152 | def f(a: Optional[Any]) -> None: ...
153 | def f(a: Annotated[Any, ...]) -> None: ...
    |          ^^^^^^^^^^^^^^^^^^^ ANN401
154 | def f(a: "Union[str, bytes, Any]") -> None: ...
    |

annotation_presence.py:154:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a`
    |
152 | def f(a: Optional[Any]) -> None: ...
153 | def f(a: Annotated[Any, ...]) -> None: ...
154 | def f(a: "Union[str, bytes, Any]") -> None: ...
    |          ^^^^^^^^^^^^^^^^^^^^^^^^ ANN401
    |

annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for special method `__init__`
    |
157 | class Foo:
158 |     @decorator()
159 |     def __init__(self: "Foo", foo: int):
    |         ^^^^^^^^ ANN204
160 |        ...
    |
    = help: Add return type annotation: `None`

ℹ Unsafe fix
156 156 | 
157 157 | class Foo:
158 158 |     @decorator()
159     |-    def __init__(self: "Foo", foo: int):
    159 |+    def __init__(self: "Foo", foo: int) -> None:
160 160 |        ...
161 161 | 
162 162 | 

annotation_presence.py:165:9: ANN204 [*] Missing return type annotation for special method `__init__`
    |
163 | # Regression test for: https://github.com/astral-sh/ruff/issues/7711
164 | class Class:
165 |     def __init__(self):
    |         ^^^^^^^^ ANN204
166 |         print(f"{self.attr=}")
    |
    = help: Add return type annotation: `None`

ℹ Unsafe fix
162 162 | 
163 163 | # Regression test for: https://github.com/astral-sh/ruff/issues/7711
164 164 | class Class:
165     |-    def __init__(self):
    165 |+    def __init__(self) -> None:
166 166 |         print(f"{self.attr=}")

annotation_presence.py:165:18: ANN101 Missing type annotation for `self` in method
    |
163 | # Regression test for: https://github.com/astral-sh/ruff/issues/7711
164 | class Class:
165 |     def __init__(self):
    |                  ^^^^ ANN101
166 |         print(f"{self.attr=}")
    |


