Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/autofix-pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
ARGS=()
fi

uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock "${ARGS[@]}" | tee /tmp/prek.log
uv run -- prek run --all-files --hook-stage manual --color never --skip flake8 --skip ruff-check --skip uv-lock "${ARGS[@]}" | tee /tmp/prek.log

- name: Ensure no warnings
run: "if grep -q '^warning: ' /tmp/prek.log; then exit 1; fi"
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/check-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: 3.14
python-version-file: .python-version

- name: Install uv
uses: astral-sh/setup-uv@v10.3.0
with:
enable-cache: true

- name: Install Flake8 from locked dependencies
run: uv sync --only-group lint-format

- name: Run Flake8
# TODO: Run from locked dependencies, once project's Python version has been updated to 3.14
run: uvx --python 3.14 --with "flake8-carrot>=0.1.4" --with "flake8-pyproject>=1.2"
-- flake8
run: uv run -- flake8

mypy: # yamllint disable-line rule:key-ordering
env:
Expand Down Expand Up @@ -357,4 +358,5 @@ jobs:
RELEASE_REPOSITORY: ${{github.repository}}
RELEASE_TAG: ${{github.ref_name}}
run: gh release create "${RELEASE_TAG}" --repo "${RELEASE_REPOSITORY}" --verify-tag
--generate-notes
--generate-notes --notes "$(git tag -l --format='%(contents:subject)%0a%0a%(contents:body)'
"${RELEASE_TAG}")"
18 changes: 12 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
default_install_hook_types: [pre-commit, commit-msg]
default_language_version:
python: python3.13
python: python3.15
default_stages: [pre-commit, pre-merge-commit, manual]

repos:
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.12.13
rev: 0.13.0
hooks:
- id: uv-lock
always_run: true
Expand All @@ -21,7 +21,7 @@ repos:
- id: codespell

- repo: https://github.com/tombi-toml/tombi-pre-commit
rev: v1.5.5
rev: v1.8.1
hooks:
- exclude: \A.+\.lock\Z
id: tombi-format
Expand Down Expand Up @@ -62,14 +62,14 @@ repos:
args: [--strict]

- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 44.90.1
rev: 44.150.1
hooks:
- id: renovate-config-validator
args: [--strict]
stages: [manual]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.38.0
rev: 0.38.2
hooks:
- id: check-jsonschema
args: [--schemafile, 'https://json.schemastore.org/yamllint.json'] # yamllint disable-line rule:quoted-strings
Expand Down Expand Up @@ -122,12 +122,18 @@ repos:
args: [--autofix]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.10
rev: v0.17.0
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

- repo: https://github.com/pycqa/flake8
rev: 7.4.1
hooks:
- id: flake8
additional_dependencies: [flake8-pyproject, flake8-carrot] # yamllint disable-line rule:key-ordering

- repo: https://github.com/google/yamlfmt
rev: v0.21.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.14
3.15
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/astral-sh/uv:python3.14-trixie-slim AS builder
FROM ghcr.io/astral-sh/uv:python3.15-trixie-slim AS builder

RUN apt-get update && \
apt-get upgrade -y && \
Expand All @@ -20,7 +20,7 @@ COPY utils/ /app/utils/
COPY db/ /app/db/
COPY cogs/ /app/cogs/

FROM python:3.14-slim-trixie
FROM python:3.15-slim-trixie

RUN groupadd --system --gid 999 nonroot && useradd --system --gid 999 --uid 999 --create-home nonroot

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TeX-Bot-Py-V2

[![Python Version](https://img.shields.io/badge/Python-3.13-blue?&logo=Python&logoColor=white)](https://python.org/downloads/release/python-3139)
[![Python Version](https://img.shields.io/badge/Python-3.15-blue?&logo=Python&logoColor=white)](https://python.org/downloads/release/python-3139)
[![Pycord Version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Ftoml-version-finder.carrotmanmatt.com%2Flock%2FCSSUoB%2FTeX-Bot-Py-V2%2Fpy-cord&query=%24.package_version&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM6dj0iaHR0cHM6Ly92ZWN0YS5pby9uYW5vIj48cGF0aCBkPSJNMTQuMjUuMThsLjkuMi43My4yNi41OS4zLjQ1LjMyLjM0LjM0LjI1LjM0LjE2LjMzLjEuMy4wNC4yNi4wMi4yLS4wMS4xM1Y4LjVsLS4wNS42My0uMTMuNTUtLjIxLjQ2LS4yNi4zOC0uMy4zMS0uMzMuMjUtLjM1LjE5LS4zNS4xNC0uMzMuMS0uMy4wNy0uMjYuMDQtLjIxLjAySDguNzdsLS42OS4wNS0uNTkuMTQtLjUuMjItLjQxLjI3LS4zMy4zMi0uMjcuMzUtLjIuMzYtLjE1LjM3LS4xLjM1LS4wNy4zMi0uMDQuMjctLjAyLjIxdjMuMDZIMy4xN2wtLjIxLS4wMy0uMjgtLjA3LS4zMi0uMTItLjM1LS4xOC0uMzYtLjI2LS4zNi0uMzYtLjM1LS40Ni0uMzItLjU5LS4yOC0uNzMtLjIxLS44OC0uMTQtMS4wNS0uMDUtMS4yMy4wNi0xLjIyLjE2LTEuMDQuMjQtLjg3LjMyLS43MS4zNi0uNTcuNC0uNDQuNDItLjMzLjQyLS4yNC40LS4xNi4zNi0uMS4zMi0uMDUuMjQtLjAxaC4xNmwuMDYuMDFoOC4xNnYtLjgz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tLjEzdi01LjM0bC4wNS0uNjQuMTMtLjU0LjIxLS40Ni4yNi0uMzguMy0uMzIuMzMtLjI0LjM1LS4yLjM1LS4xNC4zMy0uMS4zLS4wNi4yNi0uMDQuMjEtLjAyLjEzLS4wMWg1Ljg0bC42OS0uMDUuNTktLjE0LjUtLjIxLjQxLS4yOC4zMy0uMzIuMjctLjM1LjItLjM2LjE1LS4zNi4xLS4zNS4wNy0uMzIuMDQtLjI4LjAyLS4yMVY2LjA3aDIuMDlsLjE0LjAxLjIxLjAzeiIgZmlsbD0iI2Q0ZDRkNCIvPjwvc3ZnPg==&label=Pycord)](https://pycord.dev)
[![Tests Status](https://github.com/CSSUoB/TeX-Bot-Py-V2/actions/workflows/check-build-deploy.yaml/badge.svg)](https://github.com/CSSUoB/TeX-Bot-Py-V2/actions/workflows/check-build-deploy.yaml)
[![mypy Status](https://img.shields.io/badge/mypy-checked-%232EBB4E&label=mypy)](https://mypy-lang.org)
Expand Down
84 changes: 40 additions & 44 deletions cogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,46 @@
cogs for each activity.
"""

from typing import TYPE_CHECKING
__all__: Sequence[str] = (
"AddUsersToThreadsAndChannelsCommandsCog",
"AnnualRolesResetCommandCog",
"AnnualYearChannelsIncrementCommandCog",
"ArchiveCommandsCog",
"CheckSUPlatformAuthorisationCommandCog",
"CheckSUPlatformAuthorisationTaskCog",
"CommandErrorCog",
"CommitteeActionsTrackingContextCommandCog",
"CommitteeActionsTrackingSlashCommandsCog",
"CommitteeHandoverCommandCog",
"DeleteAllCommandsCog",
"EditMessageCommandCog",
"EnsureMembersInductedCommandCog",
"EverestCommandCog",
"InductContextCommandsCog",
"InductSendMessageCog",
"InductSlashCommandCog",
"InviteLinkCommandCog",
"KillCommandCog",
"MakeApplicantContextCommandsCog",
"MakeApplicantSlashCommandCog",
"MakeMemberCommandCog",
"ManualModerationCog",
"MemberCountCommandCog",
"PingCommandCog",
"SendGetRolesRemindersTaskCog",
"SendIntroductionRemindersTaskCog",
"SourceCommandCog",
"StartupCog",
"StatsCommandsCog",
"StrikeCommandsCog",
"StrikeContextCommandsCog",
"WriteRolesCommandCog",
"setup",
)

lazy from collections.abc import Iterable, Sequence

lazy from utils import TeXBot, TeXBotBaseCog

from .add_users_to_threads_and_channels import AddUsersToThreadsAndChannelsCommandsCog
from .annual_handover_and_reset import (
Expand Down Expand Up @@ -45,49 +84,6 @@
from .strike import ManualModerationCog, StrikeCommandsCog, StrikeContextCommandsCog
from .write_roles import WriteRolesCommandCog

if TYPE_CHECKING:
from collections.abc import Iterable, Sequence

from utils import TeXBot, TeXBotBaseCog

__all__: Sequence[str] = (
"AddUsersToThreadsAndChannelsCommandCog",
"AnnualRolesResetCommandCog",
"AnnualYearChannelsIncrementCommandCog",
"ArchiveCommandCog",
"CheckSUPlatformAuthorisationCommandCog",
"CheckSUPlatformAuthorisationTaskCog",
"ClearRemindersBacklogTaskCog",
"CommandErrorCog",
"CommitteeActionsTrackingContextCommandsCog",
"CommitteeActionsTrackingSlashCommandsCog",
"CommitteeHandoverCommandCog",
"DeleteAllCommandsCog",
"EditMessageCommandCog",
"EnsureMembersInductedCommandCog",
"EverestCommandCog",
"InductContextCommandsCog",
"InductSendMessageCog",
"InductSlashCommandCog",
"InviteLinkCommandCog",
"KillCommandCog",
"MakeApplicantContextCommandsCog",
"MakeApplicantSlashCommandCog",
"MakeMemberCommandCog",
"ManualModerationCog",
"MemberCountCommandCog",
"PingCommandCog",
"SendGetRolesRemindersTaskCog",
"SendIntroductionRemindersTaskCog",
"SourceCommandCog",
"StartupCog",
"StatsCommandsCog",
"StrikeCommandCog",
"StrikeContextCommandsCog",
"WriteRolesCommandCog",
"setup",
)


def setup(bot: TeXBot) -> None:
"""Add all the cogs to the bot, at bot startup."""
Expand Down
30 changes: 10 additions & 20 deletions cogs/add_users_to_threads_and_channels.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
"""Contains Cog classes for adding users and roles to threads."""

__all__: Sequence[str] = ("AddUsersToThreadsAndChannelsCommandsCog",)

import logging
from collections.abc import Iterable
from collections.abc import Set as AbstractSet # noqa: TC003
from typing import TYPE_CHECKING
lazy from collections.abc import Iterable, Sequence
lazy from collections.abc import Set as AbstractSet
lazy from logging import Logger
lazy from typing import Final

import discord

from config import settings
from exceptions import GuestRoleDoesNotExistError, GuildDoesNotExistError
from utils import (
CommandChecks,
TeXBotApplicationContext, # noqa: TC001
TeXBotAutocompleteContext, # noqa: TC001
TeXBotBaseCog,
)
from utils import CommandChecks, TeXBotBaseCog
from utils.error_capture_decorators import capture_guild_does_not_exist_error

if TYPE_CHECKING:
from collections.abc import Sequence
from logging import Logger
from typing import Final


__all__: Sequence[str] = ("AddUsersToThreadsAndChannelsCommandsCog",)

lazy from config import settings
lazy from exceptions import GuestRoleDoesNotExistError, GuildDoesNotExistError
lazy from utils import TeXBotApplicationContext, TeXBotAutocompleteContext

logger: Final[Logger] = logging.getLogger("TeX-Bot")

Expand Down
41 changes: 19 additions & 22 deletions cogs/annual_handover_and_reset.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
"""Contains cog classes for annual handover and role reset functionality."""

import datetime
import logging
from typing import TYPE_CHECKING

import discord

from config import settings
from db.core.models import GroupMadeMember
from utils import CommandChecks, TeXBotApplicationContext, TeXBotBaseCog # noqa: TC001

if TYPE_CHECKING:
from collections.abc import Collection, Mapping, Sequence
from logging import Logger
from typing import Final

from utils import AllChannelTypes

__all__: Sequence[str] = (
"AnnualRolesResetCommandCog",
"AnnualYearChannelsIncrementCommandCog",
"CommitteeHandoverCommandCog",
)

import logging
lazy import datetime
lazy from collections.abc import Collection, Mapping, Sequence
lazy from logging import Logger
lazy from typing import Final

import discord

from utils import CommandChecks, TeXBotBaseCog
lazy from config import settings
lazy from db.core.models import GroupMadeMember
lazy from utils import AllChannelTypes, TeXBotApplicationContext

logger: Final[Logger] = logging.getLogger("TeX-Bot")

Expand Down Expand Up @@ -205,11 +200,13 @@ async def annual_roles_reset(self, ctx: TeXBotApplicationContext) -> None:
f'{ctx.user} used TeX-Bot slash-command: "/annual-roles-reset"'
)

membership_dependent_roles: Mapping[str, discord.Role] = {
role.name: role
for role in main_guild.roles
if role.name in settings["MEMBERSHIP_DEPENDENT_ROLES"]
}
membership_dependent_roles: Mapping[str, discord.Role] = frozendict(
{
role.name: role
for role in main_guild.roles
if role.name in settings["MEMBERSHIP_DEPENDENT_ROLES"]
}
)

not_found_role_names: Collection[str] = settings[
"MEMBERSHIP_DEPENDENT_ROLES"
Expand Down
32 changes: 11 additions & 21 deletions cogs/archive.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
"""Contains cog classes for any archival interactions."""

__all__: Sequence[str] = ("ArchiveCommandsCog",)

import logging
import re
from collections.abc import Set as AbstractSet # noqa: TC003
from typing import TYPE_CHECKING
lazy import re
lazy from collections.abc import Sequence
lazy from collections.abc import Set as AbstractSet
lazy from logging import Logger
lazy from typing import Final

import discord

from exceptions import EveryoneRoleCouldNotBeRetrievedError
from exceptions.base import BaseDoesNotExistError
from utils import (
CommandChecks,
TeXBotApplicationContext, # noqa: TC001
TeXBotAutocompleteContext, # noqa: TC001
TeXBotBaseCog,
)

if TYPE_CHECKING:
from collections.abc import Sequence
from logging import Logger
from typing import Final

from utils import AllChannelTypes

__all__: Sequence[str] = ("ArchiveCommandsCog",)

from utils import CommandChecks, TeXBotBaseCog
lazy from exceptions import EveryoneRoleCouldNotBeRetrievedError
lazy from exceptions.base import BaseDoesNotExistError
lazy from utils import AllChannelTypes, TeXBotApplicationContext, TeXBotAutocompleteContext

logger: Final[Logger] = logging.getLogger("TeX-Bot")

Expand Down
Loading
Loading