Skip to content

Commit 730311f

Browse files
authored
Merge branch 'main' into main
2 parents 039e917 + 1546ba6 commit 730311f

File tree

15 files changed

+1457
-2870
lines changed

15 files changed

+1457
-2870
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: 2
2+
enable-beta-ecosystems: true
23
updates:
3-
- package-ecosystem: "pip"
4+
- package-ecosystem: "uv"
45
directory: "/"
56
schedule:
67
interval: "daily"

.github/workflows/lint-test.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ jobs:
77
lint-test:
88
runs-on: ubuntu-latest
99
env:
10-
# List of licenses that are compatible with the MIT License and
11-
# can be used in our project
12-
ALLOWED_LICENSE: Apache Software License;
13-
BSD License;
14-
GNU Library or Lesser General Public License (LGPL);
15-
ISC License (ISCL);
16-
MIT License;
17-
Mozilla Public License 2.0 (MPL 2.0);
18-
Public Domain;
19-
Python Software Foundation License;
20-
The Unlicense (Unlicense)
21-
2210
# Dummy values for required bot environment variables
2311
BOT_API_KEY: foo
2412
BOT_SENTRY_DSN: blah
@@ -31,27 +19,15 @@ jobs:
3119
- name: Checkout repository
3220
uses: actions/checkout@v4
3321

34-
- name: Install Python Dependencies
35-
uses: HassanAbouelela/actions/setup-python@setup-python_v1.6.0
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v6
3624
with:
37-
python_version: '3.12'
38-
39-
# Check all of our non-dev dependencies are compatible with the MIT license.
40-
# If you added a new dependencies that is being rejected,
41-
# please make sure it is compatible with the license for this project,
42-
# and add it to the ALLOWED_LICENSE variable
25+
enable-cache: true
26+
cache-dependency-glob: "uv.lock"
27+
activate-environment: true
4328

44-
# NOTE: at time of writing pip-licenses is not PEP-639 compliant
45-
# so is not detecting the license for packages now following that style.
46-
# As a temp fix, add packages to the ignore list after manually checking
47-
# that the license in use is compatible with ours.
48-
# Ref: https://github.com/raimon49/pip-licenses/issues/225
49-
- name: Check Dependencies License
50-
run: |
51-
poetry self add poetry-plugin-export
52-
pip-licenses --allow-only="$ALLOWED_LICENSE" \
53-
--ignore-packages attrs \
54-
--package $(poetry export -f requirements.txt --without-hashes | sed "s/==.*//g" | tr "\n" " ")
29+
- name: Install dependencies
30+
run: uv sync --frozen
5531

5632
- name: Run pre-commit hooks
5733
run: SKIP=ruff pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- id: ruff
1414
name: ruff
1515
description: Run ruff linting
16-
entry: poetry run ruff check --force-exclude
16+
entry: uv run --frozen ruff check --force-exclude
1717
language: system
1818
'types_or': [python, pyi]
1919
require_serial: true

Dockerfile

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3.12-slim
1+
ARG python_version=3.13-slim
2+
3+
FROM python:$python_version AS builder
4+
COPY --from=ghcr.io/astral-sh/uv:0.7 /uv /bin/
5+
6+
ENV UV_COMPILE_BYTECODE=1 \
7+
UV_LINK_MODE=copy
8+
9+
# Install project dependencies with build tools available
10+
WORKDIR /build
11+
12+
RUN --mount=type=cache,target=/root/.cache/uv \
13+
--mount=type=bind,source=uv.lock,target=uv.lock \
14+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
15+
uv sync --frozen --no-dev
16+
17+
# -------------------------------------------------------------------------------
18+
19+
FROM python:$python_version
220

321
# Define Git SHA build argument for sentry
422
ARG git_sha="development"
523
ENV GIT_SHA=$git_sha
624

7-
# Install project dependencies
8-
WORKDIR /bot
9-
COPY pyproject.toml poetry.lock ./
10-
RUN poetry install --without dev
25+
# Install dependencies from build cache
26+
# .venv not put in /app so that it doesn't conflict with the dev
27+
# volume we use to avoid rebuilding image every code change locally
28+
COPY --from=builder /build /build
29+
ENV PATH="/build/.venv/bin:$PATH"
1130

1231
# Copy the source code in last to optimize rebuilding the image
32+
WORKDIR /bot
1333
COPY . .
1434

15-
ENTRYPOINT ["poetry"]
16-
CMD ["run", "python", "-m", "bot"]
35+
ENTRYPOINT ["python", "-m"]
36+
CMD ["bot"]

bot/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ class _PythonNews(EnvConfig, env_prefix="python_news_"):
362362
class _VoiceGate(EnvConfig, env_prefix="voice_gate_"):
363363

364364
delete_after_delay: int = 60
365-
minimum_activity_blocks: int = 3
365+
minimum_activity_blocks: int = 9 # 1h30m
366366
minimum_days_member: int = 3
367-
minimum_messages: int = 50
367+
minimum_messages: int = 25
368368

369369

370370
VoiceGate = _VoiceGate()

bot/exts/moderation/alts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ async def alt_info_command(
159159
empty=True,
160160
max_lines=3,
161161
max_size=1000,
162+
allowed_roles=constants.MODERATION_ROLES,
162163
)
163164

164165
async def cog_check(self, ctx: commands.Context) -> bool:

bot/exts/moderation/infraction/management.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ async def send_infraction_list(
421421
prefix=f"{prefix}\n",
422422
empty=True,
423423
max_lines=3,
424-
max_size=1000
424+
max_size=1000,
425+
allowed_roles=constants.MODERATION_ROLES,
425426
)
426427

427428
def infraction_to_string(self, infraction: dict[str, t.Any], ignore_fields: tuple[str, ...]) -> str:

bot/exts/recruitment/talentpool/_cog.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,13 @@ async def show_nominations_list(
330330
title="Talent Pool active nominations",
331331
color=Color.blue()
332332
)
333-
await LinePaginator.paginate(lines, ctx, embed, empty=False)
333+
await LinePaginator.paginate(
334+
lines,
335+
ctx,
336+
embed,
337+
empty=False,
338+
allowed_roles=MODERATION_ROLES,
339+
)
334340

335341
async def list_nominations(
336342
self,
@@ -573,7 +579,8 @@ async def history_command(self, ctx: Context, user: MemberOrUser) -> None:
573579
embed=embed,
574580
empty=True,
575581
max_lines=3,
576-
max_size=1000
582+
max_size=1000,
583+
allowed_roles=MODERATION_ROLES,
577584
)
578585

579586
@nomination_group.command(name="end", aliases=("unwatch", "unnominate"), root_aliases=("unnominate",))

bot/exts/utils/extensions.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import functools
21
import typing as t
3-
from enum import Enum
2+
from enum import Enum, member
43

54
from discord import Colour, Embed
65
from discord.ext import commands
@@ -23,10 +22,9 @@
2322
class Action(Enum):
2423
"""Represents an action to perform on an extension."""
2524

26-
# Need to be partial otherwise they are considered to be function definitions.
27-
LOAD = functools.partial(Bot.load_extension)
28-
UNLOAD = functools.partial(Bot.unload_extension)
29-
RELOAD = functools.partial(Bot.reload_extension)
25+
LOAD = member(Bot.load_extension)
26+
UNLOAD = member(Bot.unload_extension)
27+
RELOAD = member(Bot.reload_extension)
3028

3129

3230
class Extensions(commands.Cog):

bot/exts/utils/reminders.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ async def list_reminders(self, ctx: Context) -> None:
574574

575575
await LinePaginator.paginate(
576576
lines,
577-
ctx, embed,
577+
ctx,
578+
embed,
578579
max_lines=3,
579580
)
580581

0 commit comments

Comments
 (0)