---
source: crates/ruff/src/rules/tryceratops/mod.rs
---
TRY004.py:12:9: TRY004 Prefer `TypeError` exception for invalid type
   |
12 |         pass
13 |     else:
14 |         raise Exception("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:19:9: TRY004 Prefer `TypeError` exception for invalid type
   |
19 |         pass
20 |     else:
21 |         raise Exception("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:30:9: TRY004 Prefer `TypeError` exception for invalid type
   |
30 |         pass
31 |     else:
32 |         raise Exception("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:37:9: TRY004 Prefer `TypeError` exception for invalid type
   |
37 |         pass
38 |     else:
39 |         raise Exception("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:44:9: TRY004 Prefer `TypeError` exception for invalid type
   |
44 |         pass
45 |     else:
46 |         raise ArithmeticError("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:51:9: TRY004 Prefer `TypeError` exception for invalid type
   |
51 |         pass
52 |     else:
53 |         raise AssertionError("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:58:9: TRY004 Prefer `TypeError` exception for invalid type
   |
58 |         pass
59 |     else:
60 |         raise AttributeError("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:65:9: TRY004 Prefer `TypeError` exception for invalid type
   |
65 |         pass
66 |     else:
67 |         raise BufferError  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:72:9: TRY004 Prefer `TypeError` exception for invalid type
   |
72 |         pass
73 |     else:
74 |         raise EOFError("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:79:9: TRY004 Prefer `TypeError` exception for invalid type
   |
79 |         pass
80 |     else:
81 |         raise ImportError("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:86:9: TRY004 Prefer `TypeError` exception for invalid type
   |
86 |         pass
87 |     else:
88 |         raise LookupError("...")  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
   |

TRY004.py:95:9: TRY004 Prefer `TypeError` exception for invalid type
   |
95 |           # should be typeerror
96 |           # not multiline is on purpose for fix
97 |           raise MemoryError(
   |  _________^
98 | |             "..."
99 | |         )
   | |_________^ TRY004
   |

TRY004.py:104:9: TRY004 Prefer `TypeError` exception for invalid type
    |
104 |         pass
105 |     else:
106 |         raise NameError("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:111:9: TRY004 Prefer `TypeError` exception for invalid type
    |
111 |         pass
112 |     else:
113 |         raise ReferenceError("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:118:9: TRY004 Prefer `TypeError` exception for invalid type
    |
118 |         pass
119 |     else:
120 |         raise RuntimeError("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:125:9: TRY004 Prefer `TypeError` exception for invalid type
    |
125 |         pass
126 |     else:
127 |         raise SyntaxError("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:132:9: TRY004 Prefer `TypeError` exception for invalid type
    |
132 |         pass
133 |     else:
134 |         raise SystemError("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:139:9: TRY004 Prefer `TypeError` exception for invalid type
    |
139 |         pass
140 |     else:
141 |         raise ValueError("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:146:9: TRY004 Prefer `TypeError` exception for invalid type
    |
146 |         pass
147 |     else:
148 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:153:9: TRY004 Prefer `TypeError` exception for invalid type
    |
153 |         pass
154 |     else:
155 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:160:9: TRY004 Prefer `TypeError` exception for invalid type
    |
160 |         pass
161 |     else:
162 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:167:9: TRY004 Prefer `TypeError` exception for invalid type
    |
167 |         pass
168 |     else:
169 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:174:9: TRY004 Prefer `TypeError` exception for invalid type
    |
174 |         pass
175 |     else:
176 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:181:9: TRY004 Prefer `TypeError` exception for invalid type
    |
181 |         pass
182 |     else:
183 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:188:9: TRY004 Prefer `TypeError` exception for invalid type
    |
188 |         pass
189 |     else:
190 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:195:9: TRY004 Prefer `TypeError` exception for invalid type
    |
195 |         pass
196 |     else:
197 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:202:9: TRY004 Prefer `TypeError` exception for invalid type
    |
202 |         pass
203 |     else:
204 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:209:9: TRY004 Prefer `TypeError` exception for invalid type
    |
209 |         pass
210 |     else:
211 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:216:9: TRY004 Prefer `TypeError` exception for invalid type
    |
216 |         pass
217 |     else:
218 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:223:9: TRY004 Prefer `TypeError` exception for invalid type
    |
223 |         pass
224 |     else:
225 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:230:9: TRY004 Prefer `TypeError` exception for invalid type
    |
230 |         pass
231 |     elif isinstance(arg2, int):
232 |         raise Exception("...")  # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:267:9: TRY004 Prefer `TypeError` exception for invalid type
    |
267 | def check_body(some_args):
268 |     if isinstance(some_args, int):
269 |         raise ValueError("...") # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^ TRY004
    |

TRY004.py:277:9: TRY004 Prefer `TypeError` exception for invalid type
    |
277 | def multiple_elifs(some_args):
278 |     if not isinstance(some_args, int):
279 |         raise ValueError("...") # should be typerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^ TRY004
280 |     elif some_args < 3:
281 |         raise ValueError("...")  # this is ok
    |

TRY004.py:288:9: TRY004 Prefer `TypeError` exception for invalid type
    |
288 | def multiple_ifs(some_args):
289 |     if not isinstance(some_args, int):
290 |         raise ValueError("...") # should be typerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^ TRY004
291 |     else:
292 |         if some_args < 3:
    |


