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

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

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

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

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

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

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

TRY004 Prefer `TypeError` exception for invalid type
  --> TRY004.py:65:9
   |
63 |         pass
64 |     else:
65 |         raise BufferError  # should be typeerror
   |         ^^^^^^^^^^^^^^^^^
   |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

TRY004 Prefer `TypeError` exception for invalid type
   --> TRY004.py:239:9
    |
237 |         pass
238 |     else:
239 |         raise Exception("...")   # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^
    |

TRY004 Prefer `TypeError` exception for invalid type
   --> TRY004.py:276:9
    |
274 | def check_body(some_args):
275 |     if isinstance(some_args, int):
276 |         raise ValueError("...") # should be typeerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^
    |

TRY004 Prefer `TypeError` exception for invalid type
   --> TRY004.py:286:9
    |
284 | def multiple_elifs(some_args):
285 |     if not isinstance(some_args, int):
286 |         raise ValueError("...") # should be typerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^
287 |     elif some_args < 3:
288 |         raise ValueError("...")  # this is ok
    |

TRY004 Prefer `TypeError` exception for invalid type
   --> TRY004.py:297:9
    |
295 | def multiple_ifs(some_args):
296 |     if not isinstance(some_args, int):
297 |         raise ValueError("...") # should be typerror
    |         ^^^^^^^^^^^^^^^^^^^^^^^
298 |     else:
299 |         if some_args < 3:
    |

TRY004 Prefer `TypeError` exception for invalid type
   --> TRY004.py:316:9
    |
314 |         return "CronExpression"
315 |     else:
316 |         raise Exception(f"Unknown object type: {obj.__class__.__name__}")
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
