Skip to content

Commit 1aa5068

Browse files
maresbWhyNotHugo
authored andcommitted
Don't return None in Code 39 calculate_checksum
1 parent 6109484 commit 1aa5068

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

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

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

0 commit comments

Comments
 (0)