Skip to content

Commit

Permalink
bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Fogapod committed Jul 21, 2024
1 parent 272248f commit f228e3f
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
^.*.md$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
rev: v0.5.4
hooks:
- id: ruff-format
- id: ruff
Expand Down
36 changes: 24 additions & 12 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements/base.in -o requirements/base.txt
# uv pip compile requirements/base.in -qo requirements/base.txt
aiocache==0.12.2
# via -r requirements/base.in
aiodns==3.2.0
# via discord-py
aiohttp==3.9.5
# via discord-py
aiosignal==1.3.1
# via aiohttp
anyio==4.3.0
anyio==4.4.0
# via httpx
attrs==23.2.0
# via aiohttp
brotli==1.1.0
# via discord-py
certifi==2024.2.2
certifi==2024.7.4
# via
# httpcore
# httpx
# sentry-sdk
cffi==1.16.0
# via pycares
discord-py==2.3.2
discord-py==2.4.0
# via -r requirements/base.in
frozenlist==1.4.1
# via
# aiohttp
# aiosignal
googletrans-py==4.0.0
# via -r requirements/base.in
h11==0.14.0
# via httpcore
h2==4.1.0
# via googletrans-py
hiredis==2.3.2
hiredis==3.0.0
# via redis
hpack==4.0.0
# via h2
Expand All @@ -49,22 +52,31 @@ multidict==6.0.5
# via
# aiohttp
# yarl
orjson==3.10.1
# via discord-py
pillow==10.3.0
orjson==3.10.6
# via
# -r requirements/base.in
# discord-py
pillow==10.4.0
# via -r requirements/base.in
pink-accents==0.1.1
# via -r requirements/base.in
pycares==4.4.0
# via aiodns
pycparser==2.22
# via cffi
redis==5.0.4
sentry-sdk==2.0.1
redis==5.0.7
# via -r requirements/base.in
sentry-sdk==2.10.0
# via -r requirements/base.in
sniffio==1.3.1
# via
# anyio
# httpx
urllib3==2.2.1
urllib3==2.2.2
# via sentry-sdk
uvloop==0.19.0
# via -r requirements/base.in
yarl==1.9.4
# via aiohttp
# via
# -r requirements/base.in
# aiohttp
107 changes: 78 additions & 29 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,85 +1,134 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements/dev.in -o requirements/dev.txt
# uv pip compile requirements/dev.in -qo requirements/dev.txt
aiocache==0.12.2
# via -r requirements/base.txt
aiodns==3.2.0
# via -r requirements/base.txt
aiohttp==3.9.5
# via discord-py
# via
# -r requirements/base.txt
# discord-py
aiosignal==1.3.1
# via aiohttp
anyio==4.3.0
# via httpx
# via
# -r requirements/base.txt
# aiohttp
anyio==4.4.0
# via
# -r requirements/base.txt
# httpx
attrs==23.2.0
# via aiohttp
# via
# -r requirements/base.txt
# aiohttp
brotli==1.1.0
certifi==2024.2.2
# via -r requirements/base.txt
certifi==2024.7.4
# via
# -r requirements/base.txt
# httpcore
# httpx
# sentry-sdk
cffi==1.16.0
# via
# -r requirements/base.txt
# cryptography
# pycares
cryptography==42.0.5
cryptography==43.0.0
# via
# types-pyopenssl
# types-redis
discord-py==2.3.2
discord-py==2.4.0
# via -r requirements/base.txt
frozenlist==1.4.1
# via
# -r requirements/base.txt
# aiohttp
# aiosignal
googletrans-py==4.0.0
# via -r requirements/base.txt
h11==0.14.0
# via httpcore
# via
# -r requirements/base.txt
# httpcore
h2==4.1.0
# via googletrans-py
hiredis==2.3.2
# via
# -r requirements/base.txt
# googletrans-py
hiredis==3.0.0
# via -r requirements/base.txt
hpack==4.0.0
# via h2
# via
# -r requirements/base.txt
# h2
httpcore==1.0.5
# via httpx
# via
# -r requirements/base.txt
# httpx
httpx==0.27.0
# via googletrans-py
# via
# -r requirements/base.txt
# googletrans-py
hyperframe==6.0.1
# via h2
# via
# -r requirements/base.txt
# h2
idna==3.7
# via
# -r requirements/base.txt
# anyio
# httpx
# yarl
multidict==6.0.5
# via
# -r requirements/base.txt
# aiohttp
# yarl
mypy==1.10.0
mypy==1.11.0
# via -r requirements/dev.in
mypy-extensions==1.0.0
# via mypy
orjson==3.10.1
pillow==10.3.0
orjson==3.10.6
# via -r requirements/base.txt
pillow==10.4.0
# via -r requirements/base.txt
pink-accents==0.1.1
# via -r requirements/base.txt
pycares==4.4.0
# via aiodns
# via
# -r requirements/base.txt
# aiodns
pycparser==2.22
# via cffi
redis==5.0.4
ruff==0.4.2
sentry-sdk==2.0.1
# via
# -r requirements/base.txt
# cffi
redis==5.0.7
# via -r requirements/base.txt
ruff==0.5.4
# via -r requirements/dev.in
sentry-sdk==2.10.0
# via -r requirements/base.txt
sniffio==1.3.1
# via
# -r requirements/base.txt
# anyio
# httpx
types-cffi==1.16.0.20240331
# via types-pyopenssl
types-pyopenssl==24.1.0.20240425
# via types-redis
types-redis==4.6.0.20240425
types-setuptools==69.5.0.20240423
# via -r requirements/dev.in
types-setuptools==70.3.0.20240710
# via types-cffi
typing-extensions==4.11.0
typing-extensions==4.12.2
# via mypy
urllib3==2.2.1
# via sentry-sdk
urllib3==2.2.2
# via
# -r requirements/base.txt
# sentry-sdk
uvloop==0.19.0
# via -r requirements/base.txt
yarl==1.9.4
# via aiohttp
# via
# -r requirements/base.txt
# aiohttp
4 changes: 2 additions & 2 deletions src/cogs/images/flies.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _get_fly_image(self, angle: int, state: int) -> Image.Image:
img = self._cached_flies[name]
else:
if self.fly_src:
img = self.fly_src.rotate(angle, expand=True) # type: ignore
img = self.fly_src.rotate(angle, expand=True)
else:
img = Image.open(Path(__file__).parent / "templates" / "flies" / f"{name}.png")

Expand All @@ -180,7 +180,7 @@ def make_frame(self) -> None:
for fly in self.flies:
fly._modified = False
img = self._get_fly_image(fly.angle, fly.state)
overlay.alpha_composite(img, (fly.pos_x, fly.pos_y)) # type: ignore
overlay.alpha_composite(img, (fly.pos_x, fly.pos_y))

self._frames.append(overlay)

Expand Down
13 changes: 7 additions & 6 deletions src/cogs/images/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Any, ClassVar, Optional

from PIL import Image as PilImage, ImageDraw, ImageFilter, ImageFont
from PIL.Image import Resampling
from pink_accents import Accent

from src.context import Context
Expand Down Expand Up @@ -40,7 +41,7 @@ class Config(BaseSettings.Config):
OCR_API_URL = "https://content-vision.googleapis.com/v1/images:annotate"
OCR_RATELIMIT = 30

FONT = ImageFont.truetype("DejaVuSans.ttf") # type: ignore
FONT = ImageFont.truetype("DejaVuSans.ttf")

_ocr_queue: asyncio.Queue[tuple[asyncio.Future[dict[str, Any]], bytes, Context]] = asyncio.Queue(5)
_task: Optional[asyncio.Task[Any]] = None
Expand Down Expand Up @@ -420,7 +421,7 @@ def _draw_trocr(src: PilImage.Image, fields: Sequence[TextField]) -> BytesIO:
cropped = src.crop(field.coords_padded)

# NOTE: next line causes segfaults if coords are wrong, debug from here
blurred = cropped.filter(ImageFilter.GaussianBlur(10)) # type: ignore
blurred = cropped.filter(ImageFilter.GaussianBlur(10))

# Does not work anymore for some reason, black stroke is good anyway
# field.inverted_avg_color = ImageOps.invert(
Expand All @@ -432,7 +433,7 @@ def _draw_trocr(src: PilImage.Image, fields: Sequence[TextField]) -> BytesIO:
for field in fields:
# TODO: figure out how to fit text into boxes with Pillow without creating
# extra images
font = FONT.font_variant(size=field.font_size)
font = FONT.font_variant(size=field.font_size) # type: ignore[no-untyped-call]

left, top, right, bottom = font.getbbox(field.text, stroke_width=field.stroke_width)
text_im = PilImage.new("RGBA", size=(right - left, bottom - top))
Expand All @@ -446,13 +447,13 @@ def _draw_trocr(src: PilImage.Image, fields: Sequence[TextField]) -> BytesIO:
stroke_fill=(0, 0, 0),
)

src.alpha_composite( # type: ignore
text_im.resize( # type: ignore
src.alpha_composite(
text_im.resize(
(
min((text_im.width, field.width)),
min((text_im.height, field.height)),
),
).rotate(field.angle, expand=True, resample=PilImage.BICUBIC), # type: ignore
).rotate(field.angle, expand=True, resample=Resampling.BICUBIC),
field.coords_padded[:2],
)

Expand Down
2 changes: 1 addition & 1 deletion src/cogs/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _get_object_for_source_inspection(
module_aliases.get,
ctx.bot.get_cog,
):
if (obj := getter(object_name)) is not None: # type: ignore[operator]
if (obj := getter(object_name)) is not None:
break
else:
return ()
Expand Down

0 comments on commit f228e3f

Please sign in to comment.