Skip to content

Commit

Permalink
fix lints and ignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
Fogapod committed Aug 25, 2024
1 parent 4b00678 commit bc8423e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
9 changes: 4 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
*
!/src
**/*

!/src/**/*.py
!/uv.lock
!/pyproject.toml
!/accents
!/accents2
!/accents2/
!/schema.sql

**/__pycache__
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ settings.toml
!/example.settings.toml

# cache
__pycache__
__pycache__/
/target
/.venv
/.mypy_cache
/.pytest_cache
/.venv/
*.egg-info/

# db
/pink.db
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ RUN : \
gifsicle \
# Font for trocr
ttf-dejavu \
&& uv sync --frozen --no-cache \
&& rm uv.lock pyproject.toml \
&& uv sync --frozen --no-cache --no-dev \
&& rm /bin/uv

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

COPY --chown=pink:pink . .
RUN rm uv.lock pyproject.toml

ENTRYPOINT ["/code/.venv/bin/python", "-m", "src"]
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ select = [
"N",
# pyupgrade
"UP",
# flake8-bandit
# most rules are stupid
# "S",
# flake8-comprehensions
"C4",
# flake8-logging-format
Expand All @@ -67,6 +64,10 @@ select = [
"RUF",
# flake8-unused-arguments
"ARG",
# perflint
"PERF",
# refurb
"FURB",
]
fixable = [
"I"
Expand Down
2 changes: 1 addition & 1 deletion src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def mention_or_prefix_regex(user_id: int, prefix: str) -> re.Pattern[str]:
choices = [re.escape(prefix), rf"<@!?{user_id}>"]

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


class Prefix:
Expand Down
9 changes: 6 additions & 3 deletions src/cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def convert(cls, _: Context, argument: str) -> datetime:
except ValueError:
continue

return parsed.replace(tzinfo=timezone.utc)
return parsed.replace(tzinfo=timezone.UTC)

raise ValueError("Could not parse date")

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

for i, word in zip(indexes, random.sample(group_words, k=len(group_words))):
for i, word in zip(indexes, random.sample(group_words, k=len(group_words)), strict=True):
# replace and copy case for each letter from old value
words[i] = "".join(
[c_new.upper() if c_old.isupper() else c_new.lower() for c_new, c_old in zip(word, words[i])]
[
c_new.upper() if c_old.isupper() else c_new.lower()
for c_new, c_old in zip(word, words[i], strict=True)
]
)

first, second = (words, nonwords) if word_was_first else (nonwords, words)
Expand Down
4 changes: 1 addition & 3 deletions src/cogs/images/flies.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ def draw_flies(
speed: int,
amount: int,
) -> Path:
flies = []
for _ in range(amount):
flies.append(Fly(speed=speed))
flies = [Fly(speed=speed) for _ in range(amount)]

filename = FlyDrawer(src, flies, steps=steps, fly_src=fly_src).run()
src.close()
Expand Down
4 changes: 1 addition & 3 deletions src/cogs/images/types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from __future__ import annotations

import asyncio
import base64
import re
import warnings

from asyncio import TimeoutError
from enum import Enum, auto
from io import BytesIO
from typing import Any, Literal, Optional
Expand Down Expand Up @@ -470,7 +468,7 @@ async def _fetch(
return await r.read()
except PINKError:
raise
except (Exception, asyncio.TimeoutError) as e:
except (Exception, TimeoutError) as e:
error = "Download error: "
if isinstance(e, TimeoutError):
error += f"timeout reached: **{timeout}s**"
Expand Down

0 comments on commit bc8423e

Please sign in to comment.