Skip to content

Commit 4c458e6

Browse files
committed
chg: format codes
1 parent a534850 commit 4c458e6

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

amzqr/amzqr.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ def run(
5353
raise ValueError(
5454
"Wrong picture! Input a filename that exists and be tailed with one of {'.jpg', '.jpeg', '.png', '.bmp', '.gif'}!"
5555
)
56-
if os.path.splitext(picture)[1].lower() == ".gif" and save_name and os.path.splitext(save_name)[1].lower() != ".gif":
56+
if (
57+
os.path.splitext(picture)[1].lower() == ".gif"
58+
and save_name
59+
and os.path.splitext(save_name)[1].lower() != ".gif"
60+
):
5761
raise ValueError(
5862
"Wrong save_name! If the picuter is .gif format, the output filename should be .gif format, too!"
5963
)
@@ -64,7 +68,8 @@ def run(
6468
if not isinstance(brightness, float):
6569
raise ValueError("Wrong brightness! Input a float-type value!")
6670
if save_name and (
67-
not isinstance(save_name, str) or os.path.splitext(save_name)[1].lower() not in (".jpg", ".jpeg", ".png", ".bmp", ".gif")
71+
not isinstance(save_name, str)
72+
or os.path.splitext(save_name)[1].lower() not in (".jpg", ".jpeg", ".png", ".bmp", ".gif")
6873
):
6974
raise ValueError(
7075
"Wrong save_name! Input a filename tailed with one of {'.jpg', '.jpeg', '.png', '.bmp', '.gif'}!"

tests/test_run_smoke.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_run_rejects_bad_version(tmp_path):
3434

3535
# --- extension validation ----------------------------------------------------
3636

37+
3738
def _make_dummy_file(path, suffix):
3839
"""Create a minimal (1×1) image file at the given path for extension tests.
3940
@@ -80,18 +81,14 @@ def test_run_rejects_unsupported_save_name_extension(tmp_path):
8081

8182
def test_run_accepts_jpeg_save_name(tmp_path):
8283
"""`.jpeg` save_name must be accepted."""
83-
ver, level, name = amzqr.run(
84-
"https://github.com", save_name="out.jpeg", save_dir=str(tmp_path)
85-
)
84+
ver, level, name = amzqr.run("https://github.com", save_name="out.jpeg", save_dir=str(tmp_path))
8685
assert os.path.isfile(name)
8786

8887

8988
def test_run_accepts_uppercase_save_name(tmp_path):
9089
"""`.JPEG` / `.PNG` save_name must be accepted case-insensitively."""
9190
for ext in ("out.JPEG", "out.PNG", "out.BMP", "out.JPG", "out.GIF"):
92-
ver, level, name = amzqr.run(
93-
"https://github.com", save_name=ext, save_dir=str(tmp_path)
94-
)
91+
ver, level, name = amzqr.run("https://github.com", save_name=ext, save_dir=str(tmp_path))
9592
assert os.path.isfile(name)
9693

9794

0 commit comments

Comments
 (0)