Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
90745eb
Replace poetry with uv in pyproject
jb3 Nov 9, 2025
1680d07
Set minimum uv version
jb3 Nov 9, 2025
1abbaaa
Replace most references to poetry with uv
jb3 Nov 9, 2025
3981e75
Update dependabot to work with uv
jb3 Nov 9, 2025
4ae521e
Change Docker dev mounted volume to just dev folder
jb3 Nov 9, 2025
a4f5f31
Convert dev Dockerfile to using uv
jb3 Nov 9, 2025
842ffe5
Update CI to use uv
jb3 Nov 9, 2025
bcc9e99
Add new Python versions to CI
jb3 Nov 9, 2025
784246d
Dependency bumps on all dependencies
jb3 Nov 9, 2025
14c15d8
Update sphinx docs to remove partial use
jb3 Nov 9, 2025
365301f
Add 12.x changelog so far
jb3 Nov 9, 2025
9439a35
Update ruff version
jb3 Nov 9, 2025
fe369f9
Updates for new Ruff version
jb3 Nov 9, 2025
a4f395c
Provide a pre-built SourceCode cog based on bot version
jb3 Nov 9, 2025
643b3b7
Update source code modules so documentation can build
jb3 Nov 9, 2025
7d13d75
Move avatar to constant
jb3 Nov 9, 2025
2ea5594
Use typed context object
jb3 Nov 9, 2025
28b7eb6
SourceType command -> text_command
jb3 Nov 9, 2025
49cc8dd
Add github icon to source footer
jb3 Nov 9, 2025
8410c1f
Add source cog to development bot
jb3 Nov 9, 2025
39a2634
Support commands that come from pydis_core
jb3 Nov 9, 2025
00bc8ad
Add changelog entry for SourceCode functionality
jb3 Nov 9, 2025
a3d35ac
Trim trailing / from GitHub Repo
jb3 Nov 9, 2025
5a25124
Replace __module__ with inspect.getmodule
jb3 Nov 9, 2025
6242c29
Move comment about tag handling
jb3 Nov 9, 2025
250d7e4
Support GITHUB_SHA for creating permalinks
jb3 Nov 9, 2025
959ba93
Include project name in footer
jb3 Nov 9, 2025
032f123
Unignore B904 (raise-without-from-inside-except)
jb3 Nov 10, 2025
2fa5aa2
Fix B904 across project (raise-without-from-except-inside)
jb3 Nov 10, 2025
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 .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
!pydis_core/
!dev/
!pyproject.toml
!poetry.lock
!uv.lock
!README.md
12 changes: 11 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
version: 2

updates:
- package-ecosystem: "pip"
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "*"
update-types:
- version-update:semver-patch
- version-update:semver-minor
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
26 changes: 18 additions & 8 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.4.2
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python_version: "3.11"
install_args: "--extras async-rediscache --only main --only doc"
enable-cache: true
resolution-strategy: "lowest"
cache-dependency-glob: "uv.lock"
activate-environment: true

- name: Install dependencies
run: uv sync --locked --group doc --extra async-rediscache

- name: Generate HTML Site
run: sphinx-build -nW -j auto -b html docs docs/build
Expand All @@ -37,11 +42,16 @@ jobs:
with:
fetch-depth: 0 # We need to check out the entire repository to find all tags

- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.4.2
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python_version: "3.11"
install_args: "--extras async-rediscache"
enable-cache: true
resolution-strategy: "lowest"
cache-dependency-glob: "uv.lock"
activate-environment: true

- name: Install dependencies
run: uv sync --locked --group doc --extra async-rediscache

- name: Build All Doc Versions
run: sphinx-multiversion docs docs/build -n -j auto
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.11", "3.12"]
python_version: ["3.11", "3.12", "3.13", "3.14"]

name: Run Linting & Test Suites
runs-on: ubuntu-latest
steps:
- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.4.2
- uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python_version: ${{ matrix.python_version }}
install_args: "--extras async-rediscache --only main --only lint --only test"
enable-cache: true
resolution-strategy: "lowest"
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python_version }}
activate-environment: true

- name: Install dependencies
run: uv sync --locked --group lint --group test --extra async-rediscache

- name: Run pre-commit hooks
run: SKIP=ruff pre-commit run --all-files
Expand All @@ -30,7 +38,7 @@ jobs:
run: python -m pytest -n auto --cov pydis_core -q

- name: Build and dry run the example bot to ensure deps can be installed & imported
run: docker run --rm --env GUILD_ID=1234 --env IN_CI=true $(docker build --build-arg python_version=${{ matrix.python_version }} -q -f ./dev/Dockerfile .) run python -m dev.bot
run: docker run --rm --env GUILD_ID=1234 --env IN_CI=true $(docker build --build-arg python_version=${{ matrix.python_version }} -q -f ./dev/Dockerfile .)

# Prepare the Pull Request Payload artifact. If this fails, we
# we fail silently using the `continue-on-error` option. It's
Expand Down
25 changes: 16 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: check-toml
Expand All @@ -11,11 +11,18 @@ repos:

- repo: local
hooks:
- id: ruff
name: ruff
description: Run ruff linting
entry: poetry run ruff check --force-exclude
language: system
'types_or': [python, pyi]
require_serial: true
args: [--fix, --exit-non-zero-on-fix]
- id: uv-lock
name: uv-lock
description: "Automatically run 'uv lock' on your project dependencies"
entry: uv lock
language: system
files: ^(uv\.lock|pyproject\.toml|uv\.toml)$
pass_filenames: false
- id: ruff
name: ruff
description: Run ruff linting
entry: uv run --locked ruff check --force-exclude
language: system
'types_or': [python, pyi]
require_serial: true
args: [--fix, --exit-non-zero-on-fix]
23 changes: 16 additions & 7 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
ARG python_version=3.11
ARG python_version=3.14-slim

FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:$python_version-slim
FROM python:$python_version AS builder
COPY --from=ghcr.io/astral-sh/uv:0.9 /uv /bin/

ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy

# Install project dependencies
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-root --only dev,main
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --no-install-project --frozen --group dev

# Copy the source code in last to optimize rebuilding the image
COPY . .

# Install again, this time with the root project
RUN poetry install --only-root
RUN uv pip install "pydis_core[all]@."

WORKDIR /app/dev
ENV PATH="/app/.venv/bin:$PATH"

ENTRYPOINT ["poetry"]
CMD ["run", "python", "-m", "bot"]
ENTRYPOINT ["python"]
CMD ["-m", "bot"]
2 changes: 1 addition & 1 deletion dev/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Option 1
- The path provided to install should be the root directory of this project on your machine.
That is, the folder which contains the ``pyproject.toml`` file.
- Make sure to install in the correct environment. Most Python Discord projects use
poetry, so you can run ``poetry run pip install /path/to/pydis_core``.
uv, so you can run ``uv run -- pip install /path/to/pydis_core``.

3. You can now use features from your local bot-core changes.
To load new changes, run the install command again.
Expand Down
2 changes: 2 additions & 0 deletions dev/bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from discord.ext import commands

import pydis_core
from pydis_core.exts.source import SourceCode

from . import Bot

Expand All @@ -30,6 +31,7 @@ async def main() -> None:
"""Run the bot."""
bot.http_session = aiohttp.ClientSession()
async with bot:
await bot.add_cog(SourceCode(bot, github_repo="https://github.com/python-discord/bot-core"))
await bot.start(os.getenv("BOT_TOKEN"))


Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ services:
context: .
dockerfile: dev/Dockerfile
volumes:
- .:/app:ro
- ./dev:/app/dev:ro
tty: true
depends_on:
- web
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Table of contents:
## Building
To build the docs, you can use the following task:
```shell
poetry run task docs
uv run task docs
```

The output will be in the [`/docs/build`](.) directory.
Expand Down Expand Up @@ -42,7 +42,7 @@ The project supports building all different versions at once using [sphinx-multi
after version `v7.1.0`. You can run the following command to achieve that:

```shell
poetry run sphinx_multiversion -v docs docs/build -n -j auto -n
uv run sphinx_multiversion -v docs docs/build -n -j auto -n
```

This will build all tags, as well as the main branch. To build branches besides the main one
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
Changelog
=========

.. XXX: CHANGE DATE BEFORE RELEASE

- :release:`12.0.0 <9th November 2025>`
- :feature:`310` Provide a pre-built :obj:`pydis_core.exts.source.SourceCode` cog for providing links to command implementations.
- :support:`309` Dependency bumps on all dependencies
- :support:`309` Migrate build system from Poetry to uv
- :support:`309` Explicit support for Python 3.13 and 3.14

- :release:`11.8.0 <1st January 1970>`
- :feature:`305` Update :obj:`pydis_core.utils.checks.in_whitelist_check` to check against the parent channel, if one exists, instead of the ``ctx.channel.id``.

Expand Down
7 changes: 4 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import contextlib
import functools
import logging
import os.path
import shutil
Expand Down Expand Up @@ -35,7 +34,7 @@
# The full version, including alpha/beta/rc tags
release = version = tomli.loads(
(PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")
)["tool"]["poetry"]["version"]
)["project"]["version"]

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -194,7 +193,9 @@ def setup(app: Sphinx) -> None:


# -- Options for the linkcode extension --------------------------------------
linkcode_resolve = functools.partial(utils.linkcode_resolve, REPO_LINK)
def linkcode_resolve(domain: str, info: dict) -> str | None:
"""Determine the URL corresponding to Python object."""
return utils.linkcode_resolve(REPO_LINK, domain, info)


# -- Options for releases extension ------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> str |
# These are ClassVars added by pydantic.
# Since they're not in our source code, we cannot resolve them to a url.
return None
raise Exception(f"Could not find symbol `{symbol_name}` in {module.__name__}.")
raise Exception(f"Could not find symbol `{symbol_name}` in {module.__name__}.") from None

start, end = pos
_, offset = inspect.getsourcelines(symbol[-2])
Expand Down
Loading