Skip to content

Commit 96d953e

Browse files
authored
fix: EM102 assign f-strings to msg before raising exceptions
1 parent e510a03 commit 96d953e

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

conversions/roman_numerals.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ def int_to_roman(number: int) -> str:
6464
TypeError: int_to_roman only accepts integers, got bool
6565
"""
6666
if not isinstance(number, int) or isinstance(number, bool):
67-
raise TypeError(
68-
f"int_to_roman only accepts integers, got {type(number).__name__}"
69-
)
67+
msg = f"int_to_roman only accepts integers, got {type(number).__name__}"
68+
raise TypeError(msg)
7069
if not 1 <= number <= 3999:
71-
raise ValueError(
72-
f"int_to_roman only accepts integers in the range 1 to 3999, got {number}"
73-
)
70+
msg = f"int_to_roman only accepts integers in the range 1 to 3999, got {number}"
71+
raise ValueError(msg)
7472
result = []
7573
for arabic, roman in ROMAN:
7674
(factor, number) = divmod(number, arabic)

0 commit comments

Comments
 (0)