Skip to content

Commit a90ebce

Browse files
committed
migrate from blackt to ruff format
1 parent 7367ff9 commit a90ebce

File tree

11 files changed

+98
-57
lines changed

11 files changed

+98
-57
lines changed

.pre-commit-config.yaml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
repos:
2-
- repo: https://github.com/FHPythonUtils/Blackt
3-
rev: '2022.0.3'
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.2.2
44
hooks:
5-
- id: blackt
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format
68

7-
- repo: https://github.com/pycqa/isort
8-
rev: 5.12.0
9+
- repo: https://github.com/RobertCraigie/pyright-python
10+
rev: v1.1.351
911
hooks:
10-
- id: isort
12+
- id: pyright
1113

12-
- repo: https://github.com/pycqa/pylint
13-
rev: v3.0.0a6
14+
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
15+
rev: v1.3.3
1416
hooks:
15-
- id: pylint
16-
exclude: "tests/"
17-
args: [--disable=import-error,--jobs=0]
17+
- id: python-safety-dependencies-check
18+
files: pyproject.toml
1819

1920
- repo: https://github.com/pre-commit/pre-commit-hooks
20-
rev: v4.4.0
21+
rev: v4.5.0
2122
hooks:
2223
- id: trailing-whitespace
23-
exclude: "tests/"
2424
- id: end-of-file-fixer
25-
exclude: "tests/"
25+
- id: check-case-conflict
26+
- id: check-executables-have-shebangs
27+
- id: check-json
28+
- id: check-merge-conflict
29+
- id: check-shebang-scripts-are-executable
30+
- id: check-symlinks
31+
- id: check-toml
32+
- id: check-vcs-permalinks
33+
- id: check-yaml
34+
- id: detect-private-key
35+
- id: mixed-line-ending
2636

27-
- repo: https://github.com/asottile/pyupgrade
28-
rev: v3.7.0
29-
hooks:
30-
- id: pyupgrade
31-
args: [--py38-plus]
3237
- repo: https://github.com/boidolr/pre-commit-images
33-
rev: v1.2.1
38+
rev: v1.5.2
3439
hooks:
35-
- id: optimize-avif
36-
exclude: "tests/"
3740
- id: optimize-jpg
38-
exclude: "tests/"
3941
- id: optimize-png
40-
exclude: "tests/"
4142
- id: optimize-svg
42-
exclude: "tests/"
4343
- id: optimize-webp
44-
exclude: "tests/"
44+
45+
exclude: "tests/data|documentation/reference"

documentation/reference/sigstickers/caching.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
11
# Caching
22

3-
[Sigstickers Index](../README.md#sigstickers-index) /
4-
[Sigstickers](./index.md#sigstickers) /
5-
Caching
3+
[Sigstickers Index](../README.md#sigstickers-index) / [Sigstickers](./index.md#sigstickers) / Caching
64

75
> Auto-generated documentation for [sigstickers.caching](../../../sigstickers/caching.py) module.
86
97
- [Caching](#caching)
8+
- [_verifyConvertedV1](#_verifyconvertedv1)
109
- [createConverted](#createconverted)
1110
- [verifyConverted](#verifyconverted)
1211

12+
## _verifyConvertedV1
13+
14+
[Show source in caching.py:37](../../../sigstickers/caching.py#L37)
15+
16+
Verify the cache for a packName using cache data
17+
18+
#### Arguments
19+
20+
data (dict[str, Any]) packName cache data to verify
21+
22+
#### Returns
23+
24+
- `bool` - if the converted cache has been verified
25+
26+
#### Signature
27+
28+
```python
29+
def _verifyConvertedV1(data: dict[str, Any]): ...
30+
```
31+
32+
33+
1334
## createConverted
1435

1536
[Show source in caching.py:52](../../../sigstickers/caching.py#L52)

documentation/reference/sigstickers/downloader.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Downloader
22

3-
[Sigstickers Index](../README.md#sigstickers-index) /
4-
[Sigstickers](./index.md#sigstickers) /
5-
Downloader
3+
[Sigstickers Index](../README.md#sigstickers-index) / [Sigstickers](./index.md#sigstickers) / Downloader
64

75
> Auto-generated documentation for [sigstickers.downloader](../../../sigstickers/downloader.py) module.
86
@@ -38,7 +36,7 @@ def assureDirExists(directory: str, root: str) -> str: ...
3836

3937
## convertPack
4038

41-
[Show source in downloader.py:112](../../../sigstickers/downloader.py#L112)
39+
[Show source in downloader.py:121](../../../sigstickers/downloader.py#L121)
4240

4341
Convert the webp images into png and gif images
4442

@@ -58,7 +56,7 @@ async def convertPack(swd: str, packName: str, noCache=False): ...
5856

5957
## convertWithPIL
6058

61-
[Show source in downloader.py:91](../../../sigstickers/downloader.py#L91)
59+
[Show source in downloader.py:96](../../../sigstickers/downloader.py#L96)
6260

6361
Convert the webp file to png
6462

documentation/reference/sigstickers/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Sigstickers
22

3-
[Sigstickers Index](../README.md#sigstickers-index) /
4-
Sigstickers
3+
[Sigstickers Index](../README.md#sigstickers-index) / Sigstickers
54

65
> Auto-generated documentation for [sigstickers](../../../sigstickers/__init__.py) module.
76
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Module
22

3-
[Sigstickers Index](../README.md#sigstickers-index) /
4-
[Sigstickers](./index.md#sigstickers) /
5-
Module
3+
[Sigstickers Index](../README.md#sigstickers-index) / [Sigstickers](./index.md#sigstickers) / Module
64

75
> Auto-generated documentation for [sigstickers.__main__](../../../sigstickers/__main__.py) module.
86
- [Module](#module)

pyproject.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ readme = "README.md"
2424
python = "^3.8"
2525
Pillow = "<11,>=10.2.0"
2626
signalstickers-client = "<4,>=3.3.0"
27-
emoji = "<3,>=2.9.0"
27+
emoji = "<3,>=2.10.1"
2828

2929
[tool.poetry.scripts]
3030
sigstickers = "sigstickers:cli"
3131

3232
[tool.poetry.group.dev.dependencies]
33-
pytest = "^7.4.4"
34-
pylint = "^3.0.3"
33+
pytest = "^8.0.2"
34+
pylint = "^3.1.0"
3535
handsdown = "^2.1.0"
36-
coverage = "^7.4.0"
36+
coverage = "^7.4.3"
37+
38+
[tool.ruff.format]
39+
indent-style = "tab"
40+
docstring-code-format = true
41+
line-ending = "lf"
3742

38-
[tool.black]
39-
line-length = 100
40-
target-version = ["py38"]
4143

4244
[tool.isort]
4345
profile = "black"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Pillow<11,>=10.2.0
2-
emoji<3,>=2.9.0
2+
emoji<3,>=2.10.1
33
signalstickers-client<4,>=3.3.0

sigstickers/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
def cli(): # pragma: no cover
1414
"""cli entry point"""
15-
parser = argparse.ArgumentParser("Welcome to SigSticker, providing all of your sticker needs")
15+
parser = argparse.ArgumentParser(
16+
"Welcome to SigSticker, providing all of your sticker needs"
17+
)
1618
parser.add_argument(
1719
"-p",
1820
"--pack",
@@ -42,7 +44,9 @@ def cli(): # pragma: no cover
4244
asyncio.run(
4345
convertPack(
4446
*asyncio.run(
45-
downloadPack("".join(packAttrs["pack_id"]), "".join(packAttrs["pack_key"]))
47+
downloadPack(
48+
"".join(packAttrs["pack_id"]), "".join(packAttrs["pack_key"])
49+
)
4650
)
4751
)
4852
)

sigstickers/downloader.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def saveSticker(sticker: Sticker, path: str) -> str:
5151
return filePath
5252

5353

54-
async def downloadPack(packId: str, packKey: str, cwd: str = os.getcwd()) -> tuple[str, str]:
54+
async def downloadPack(
55+
packId: str, packKey: str, cwd: str = os.getcwd()
56+
) -> tuple[str, str]:
5557
"""Download a sticker pack.
5658
5759
Args:
@@ -81,7 +83,10 @@ async def downloadPack(packId: str, packKey: str, cwd: str = os.getcwd()) -> tup
8183
print(f'Starting download of "{packName}" into {swd}')
8284
with ThreadPoolExecutor(max_workers=4) as executor:
8385
for i in as_completed(
84-
[executor.submit(saveSticker, sticker, webpDir) for sticker in pack.stickers]
86+
[
87+
executor.submit(saveSticker, sticker, webpDir)
88+
for sticker in pack.stickers
89+
]
8590
):
8691
i.result()
8792

@@ -102,7 +107,11 @@ def convertWithPIL(inputFile: str) -> str:
102107

103108
try:
104109
img.save(
105-
inputFile.replace("webp", "gif"), version="GIF89a", disposal=2, save_all=True, loop=0
110+
inputFile.replace("webp", "gif"),
111+
version="GIF89a",
112+
disposal=2,
113+
save_all=True,
114+
loop=0,
106115
)
107116
except ValueError:
108117
print(f"Failed to save {inputFile} as gif")
@@ -131,7 +140,9 @@ async def convertPack(swd: str, packName: str, noCache=False):
131140
stickers = [opj(webpDir, i) for i in os.listdir(webpDir)]
132141
total = len(stickers)
133142
with ThreadPoolExecutor(max_workers=4) as executor:
134-
for _ in as_completed([executor.submit(convertWithPIL, sticker) for sticker in stickers]):
143+
for _ in as_completed(
144+
[executor.submit(convertWithPIL, sticker) for sticker in stickers]
145+
):
135146
converted += 1
136147
end = time.time()
137148
print(f"Time taken to convert {converted}/{total} stickers - {end - start:.3f}s")

tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

0 commit comments

Comments
 (0)