Skip to content

Commit

Permalink
Fix ruff alert (currently) not caught by pre-commit
Browse files Browse the repository at this point in the history
TRY002 Create your own exception

I changed `Exception` to `RuntimeError`, but the exception cannot be thrown
any way. Any file can be read with encoding "iso-8859-1", UnicodeDecodeError
will never be raised with this encoding. Add "no cover" to avoid Codecov
warning.
  • Loading branch information
DimitriPapadopoulos committed Oct 21, 2023
1 parent 3a7550e commit 0d816cd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ def open_with_internal(self, filename: str) -> Tuple[List[str], str]:
else:
break
else:
# reading with encoding "iso-8859-1" cannot fail with UnicodeDecodeError
msg = "Unknown encoding"
raise Exception(msg)
raise RuntimeError(msg) # pragma: no cover

return lines, encoding

Expand Down

0 comments on commit 0d816cd

Please sign in to comment.