Skip to content

Commit 0ebabf5

Browse files
committed
Don't return None in Code 39 calculate_checksum
1 parent be340ba commit 0ebabf5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

barcode/codex.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ def get_fullcode(self) -> str:
6464
""":returns: The full code as it will be encoded."""
6565
return self.code
6666

67-
def calculate_checksum(self):
67+
def calculate_checksum(self) -> str:
6868
check = sum(code39.MAP[x][0] for x in self.code) % 43
6969
for k, v in code39.MAP.items():
7070
if check == v[0]:
7171
return k
72-
return None
72+
raise RuntimeError(
73+
"All possible values for the checksum should have been included in the map."
74+
)
7375

7476
def build(self) -> list[str]:
7577
chars = [code39.EDGE]

0 commit comments

Comments
 (0)