Skip to content

Commit 6d2b091

Browse files
committed
ruff fixes
1 parent d631542 commit 6d2b091

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

sigstickers/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" entry point for python -m sigstickers """
1+
""" entry point for python -m sigstickers. """
22

33
from sigstickers.cli import cli
44

sigstickers/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"""Download sticker packs from Signal."""
2+
from __future__ import annotations
3+
24
import argparse
35
import asyncio
6+
import functools
7+
import operator
48
from sys import exit as sysexit
59
from urllib import parse
610

@@ -21,7 +25,7 @@ def cli() -> None:
2125
)
2226
args = parser.parse_args()
2327
# Get the packs
24-
packs: list[str] = sum(args.pack or [[]], [])
28+
packs: list[str] = functools.reduce(operator.iadd, args.pack or [[]], [])
2529
if not packs:
2630
packs = []
2731
while True:
@@ -32,7 +36,7 @@ def cli() -> None:
3236
return main(packs)
3337

3438

35-
def main(packs):
39+
def main(packs) -> None:
3640
"""Main function to download sticker packs."""
3741
for pack in packs:
3842
pack_attrs: dict[str, list[str]] = parse.parse_qs(parse.urlparse(pack).fragment)

sigstickers/downloader.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ def _sanitize_filename(filename: str) -> str:
5858
sanitized_filename = re.sub(r"[^\w\s.-]", "_", filename)
5959
sanitized_filename = re.sub(r"\s+", "_", sanitized_filename)
6060
sanitized_filename = sanitized_filename.strip(" .")
61-
sanitized_filename = (
62-
unicodedata.normalize("NFKD", sanitized_filename).encode("ascii", "ignore").decode()
63-
)
64-
return sanitized_filename
61+
return unicodedata.normalize("NFKD", sanitized_filename).encode("ascii", "ignore").decode()
6562

6663

6764
async def download_pack(pack_id: str, pack_key: str, cwd: Path = Path.cwd()) -> tuple[Path, Path]:
@@ -138,7 +135,7 @@ def convert_with_pil(input_path: Path) -> list[str]:
138135
return [png_file, gif_file]
139136

140137

141-
async def convert_pack(swd: Path, pack_name: Path, *, no_cache=False):
138+
async def convert_pack(swd: Path, pack_name: Path, *, no_cache=False) -> None:
142139
"""Convert the webp images into png and gif images.
143140
144141
Args:

tests/test_caching.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
file_exists_2 = ".gitignore"
1212

1313

14-
def test_verify_converted_v1():
14+
def test_verify_converted_v1() -> None:
1515
pack_name = "Test_Pack_v1"
1616
cache_file = CACHE_DIR / pack_name
1717
cache_data = {
@@ -23,7 +23,7 @@ def test_verify_converted_v1():
2323
assert verify_converted(Path(pack_name))
2424

2525

26-
def test_verify_converted_v2():
26+
def test_verify_converted_v2() -> None:
2727
pack_name = "Test_Pack_v2"
2828
cache_file = CACHE_DIR / pack_name
2929
cache_data = {
@@ -36,7 +36,7 @@ def test_verify_converted_v2():
3636
assert verify_converted(Path(pack_name))
3737

3838

39-
def test_create_converted():
39+
def test_create_converted() -> None:
4040
pack_name = "Test_Pack"
4141
cache_data = {"example_key": "example_value"}
4242

tests/test_downloader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from sigstickers.downloader import download_pack
77

88

9-
@pytest.fixture(scope="function")
9+
@pytest.fixture()
1010
def test_data():
1111
test_dir = Path("test_data")
1212
yield test_dir
1313
shutil.rmtree(test_dir)
1414

1515

1616
@pytest.mark.asyncio()
17-
async def test_download_pack(test_data):
17+
async def test_download_pack(test_data) -> None:
1818
pack_id = "b676ec334ee2f771cadff5d095971e8c"
1919
pack_key = "c957a57000626a2dc3cb69bf0e79c91c6b196b74d4d6ca1cbb830d3ad0ad4e36"
2020
sticker_dir, _pack_name = await download_pack(pack_id, pack_key, cwd=test_data)
@@ -23,7 +23,7 @@ async def test_download_pack(test_data):
2323

2424

2525
@pytest.mark.asyncio()
26-
async def test_download_pack_bad_name(test_data):
26+
async def test_download_pack_bad_name(test_data) -> None:
2727
pack_id = "4d92b5e3e92d1ac099830b17ac10793d"
2828
pack_key = "c8526aa2e25b911a405d39c1d4ee3977586e945550fddc33e1316626116da512"
2929
sticker_dir, _pack_name = await download_pack(pack_id, pack_key, cwd=test_data)

tests/test_user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
]
2323

2424

25-
def test_downloadPack():
25+
def test_downloadPack() -> None:
2626
swd, packName = asyncio.run(
2727
downloader.download_pack(packs[0]["packId"], packs[0]["packKey"], cwd)
2828
)
@@ -33,7 +33,7 @@ def test_downloadPack():
3333
assert len(list(Path(f"{cwd}/downloads/DonutTheDog/webp").iterdir())) == packs[0]["len"]
3434

3535

36-
def test_convertPack():
36+
def test_convertPack() -> None:
3737
swd, packName = asyncio.run(
3838
downloader.download_pack(packs[0]["packId"], packs[0]["packKey"], cwd)
3939
)

0 commit comments

Comments
 (0)