Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 18, 2023
1 parent 2de29be commit bf57870
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
9 changes: 2 additions & 7 deletions barcode/ean.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,14 @@ def __init__(self, ean, writer=None, no_checksum=False, guardbar=False) -> None:
raise IllegalCharacterError("EAN code can only contain numbers.")
if len(ean) != self.digits:
raise NumberOfDigitsError(
"EAN must have {} digits, not {}.".format(
self.digits,
len(ean),
)
f"EAN must have {self.digits} digits, not {len(ean)}."
)
self.ean = ean
# If no checksum
if no_checksum:
# Add a thirteen char if given in parameter,
# otherwise pad with zero
self.ean = "{}{}".format(
ean, ean[self.digits] if len(ean) > self.digits else 0
)
self.ean = f"{ean}{ean[self.digits] if len(ean) > self.digits else 0}"
else:
self.ean = f"{ean}{self.calculate_checksum()}"

Expand Down
8 changes: 2 additions & 6 deletions barcode/pybarcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ def create_barcode(args, parser):
args.type = args.type.upper()
if args.type != "SVG" and args.type not in IMG_FORMATS:
parser.error(
"Unknown type {type}. Try list action for available types.".format(
type=args.type
)
f"Unknown type {args.type}. Try list action for available types."
)
args.barcode = args.barcode.lower()
if args.barcode not in barcode.PROVIDED_BARCODES:
parser.error(
"Unknown barcode {bc}. Try list action for available barcodes.".format(
bc=args.barcode
)
f"Unknown barcode {args.barcode}. Try list action for available barcodes."
)
if args.type != "SVG":
opts = {"format": args.type}
Expand Down
4 changes: 1 addition & 3 deletions tests/test_manually.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def append_img(x, y):
options["center_text"] = True
filename = bcode.save(os.path.join(TESTPATH, codename), options=options)
print(
"Code: {}, Input: {}, Output: {}".format(
bcode.name, code, bcode.get_fullcode()
)
f"Code: {bcode.name}, Input: {code}, Output: {bcode.get_fullcode()}"
)
append(os.path.basename(filename), bcode.name)
if ImageWriter is not None:
Expand Down

0 comments on commit bf57870

Please sign in to comment.