Skip to content

Commit 64d78fc

Browse files
committed
fix lints and ignore files
1 parent 4b00678 commit 64d78fc

File tree

8 files changed

+24
-26
lines changed

8 files changed

+24
-26
lines changed

.dockerignore

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
*
2-
!/src
1+
**/*
2+
3+
!/src/**/*.py
34
!/uv.lock
45
!/pyproject.toml
56
!/accents
6-
!/accents2
7+
!/accents2/
78
!/schema.sql
8-
9-
**/__pycache__

.gitignore

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ settings.toml
66
!/example.settings.toml
77

88
# cache
9-
__pycache__
9+
__pycache__/
1010
/target
11-
/.venv
12-
/.mypy_cache
13-
/.pytest_cache
11+
/.venv/
12+
*.egg-info/
1413

1514
# db
1615
/pink.db

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ RUN : \
2525
gifsicle \
2626
# Font for trocr
2727
ttf-dejavu \
28-
&& uv sync --frozen --no-cache \
29-
&& rm uv.lock pyproject.toml \
28+
&& uv sync --frozen --no-cache --no-dev \
3029
&& rm /bin/uv
3130

3231
COPY --from=accents_builder /build/target/release/sayit /usr/bin/sayit
@@ -48,5 +47,6 @@ RUN addgroup -g $GID -S pink \
4847
USER pink
4948

5049
COPY --chown=pink:pink . .
50+
RUN rm uv.lock pyproject.toml
5151

5252
ENTRYPOINT ["/code/.venv/bin/python", "-m", "src"]

pyproject.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ select = [
5252
"N",
5353
# pyupgrade
5454
"UP",
55-
# flake8-bandit
56-
# most rules are stupid
57-
# "S",
5855
# flake8-comprehensions
5956
"C4",
6057
# flake8-logging-format
@@ -67,6 +64,10 @@ select = [
6764
"RUF",
6865
# flake8-unused-arguments
6966
"ARG",
67+
# perflint
68+
"PERF",
69+
# refurb
70+
"FURB",
7071
]
7172
fixable = [
7273
"I"

src/bot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
def mention_or_prefix_regex(user_id: int, prefix: str) -> re.Pattern[str]:
2828
choices = [re.escape(prefix), rf"<@!?{user_id}>"]
2929

30-
return re.compile(rf"(?:{'|'.join(choices)})\s*", re.I)
30+
return re.compile(rf"(?:{'|'.join(choices)})\s*", re.IGNORECASE)
3131

3232

3333
class Prefix:

src/cogs/fun.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from collections import defaultdict
66
from collections.abc import Iterable
7-
from datetime import datetime, timezone
7+
from datetime import UTC, datetime
88
from typing import Optional
99

1010
import discord
@@ -33,7 +33,7 @@ async def convert(cls, _: Context, argument: str) -> datetime:
3333
except ValueError:
3434
continue
3535

36-
return parsed.replace(tzinfo=timezone.utc)
36+
return parsed.replace(tzinfo=UTC)
3737

3838
raise ValueError("Could not parse date")
3939

@@ -294,10 +294,13 @@ async def scramble2(self, ctx: Context, *, text: Optional[str]) -> None:
294294
indexes = [i for i, _ in group]
295295
group_words = [w for _, w in group]
296296

297-
for i, word in zip(indexes, random.sample(group_words, k=len(group_words))):
297+
for i, word in zip(indexes, random.sample(group_words, k=len(group_words)), strict=True):
298298
# replace and copy case for each letter from old value
299299
words[i] = "".join(
300-
[c_new.upper() if c_old.isupper() else c_new.lower() for c_new, c_old in zip(word, words[i])]
300+
[
301+
c_new.upper() if c_old.isupper() else c_new.lower()
302+
for c_new, c_old in zip(word, words[i], strict=True)
303+
]
301304
)
302305

303306
first, second = (words, nonwords) if word_was_first else (nonwords, words)

src/cogs/images/flies.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ def draw_flies(
228228
speed: int,
229229
amount: int,
230230
) -> Path:
231-
flies = []
232-
for _ in range(amount):
233-
flies.append(Fly(speed=speed))
231+
flies = [Fly(speed=speed) for _ in range(amount)]
234232

235233
filename = FlyDrawer(src, flies, steps=steps, fly_src=fly_src).run()
236234
src.close()

src/cogs/images/types.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from __future__ import annotations
22

3-
import asyncio
43
import base64
54
import re
65
import warnings
76

8-
from asyncio import TimeoutError
97
from enum import Enum, auto
108
from io import BytesIO
119
from typing import Any, Literal, Optional
@@ -448,7 +446,7 @@ async def _fetch(
448446
max_content_length: int = 8000000,
449447
) -> bytes:
450448
try:
451-
async with ctx.session.get(url, timeout=timeout) as r:
449+
async with ctx.session.get(url, timeout=aiohttp.ClientTimeout(total=timeout)) as r:
452450
if r.status != 200:
453451
raise PINKError(f"bad status code: **{r.status}**")
454452

@@ -470,7 +468,7 @@ async def _fetch(
470468
return await r.read()
471469
except PINKError:
472470
raise
473-
except (Exception, asyncio.TimeoutError) as e:
471+
except (Exception, TimeoutError) as e:
474472
error = "Download error: "
475473
if isinstance(e, TimeoutError):
476474
error += f"timeout reached: **{timeout}s**"

0 commit comments

Comments
 (0)