Skip to content

Commit 20a4998

Browse files
committed
Don't return None in Code 39 calculate_checksum
1 parent ce5d026 commit 20a4998

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
@@ -59,12 +59,14 @@ def get_fullcode(self) -> str:
5959
""":returns: The full code as it will be encoded."""
6060
return self.code
6161

62-
def calculate_checksum(self):
62+
def calculate_checksum(self) -> str:
6363
check = sum(code39.MAP[x][0] for x in self.code) % 43
6464
for k, v in code39.MAP.items():
6565
if check == v[0]:
6666
return k
67-
return None
67+
raise RuntimeError(
68+
"All possible values for the checksum should have been included in the map."
69+
)
6870

6971
def build(self):
7072
chars = [code39.EDGE]

0 commit comments

Comments
 (0)