From 4a91a2648e30c398a1b1c3d17819d06d1b71e2d6 Mon Sep 17 00:00:00 2001 From: Stuart Maxwell Date: Tue, 15 Oct 2024 11:04:45 +1300 Subject: [PATCH 1/2] Update pre-commit --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1af6296..bd12fce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.11 + python: python3.13 repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -16,7 +16,7 @@ repos: rev: "1.22.1" # replace with latest tag on GitHub hooks: - id: django-upgrade - args: [--target-version, "4.2"] # Replace with Django version + args: [--target-version, "5.1"] # Replace with Django version - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.6.9 From dea6b357c863eab7232d87f179b66a0039057739 Mon Sep 17 00:00:00 2001 From: Stuart Maxwell Date: Tue, 15 Oct 2024 11:04:50 +1300 Subject: [PATCH 2/2] Add shell application to enable new repl --- config/settings.py | 1 + shell/__init__.py | 1 + shell/apps.py | 10 ++++++++++ shell/management/commands/__init__.py | 1 + shell/management/commands/shell.py | 17 +++++++++++++++++ shell/migrations/__init__.py | 0 6 files changed, 30 insertions(+) create mode 100644 shell/__init__.py create mode 100644 shell/apps.py create mode 100644 shell/management/commands/__init__.py create mode 100644 shell/management/commands/shell.py create mode 100644 shell/migrations/__init__.py diff --git a/config/settings.py b/config/settings.py index 6edf8bd..f04a9cd 100644 --- a/config/settings.py +++ b/config/settings.py @@ -70,6 +70,7 @@ "djpress.apps.DjpressConfig", "timezone_converter", "markdown_editor", + "shell", ] if DEBUG: diff --git a/shell/__init__.py b/shell/__init__.py new file mode 100644 index 0000000..0442467 --- /dev/null +++ b/shell/__init__.py @@ -0,0 +1 @@ +"""Shell application package.""" diff --git a/shell/apps.py b/shell/apps.py new file mode 100644 index 0000000..a694088 --- /dev/null +++ b/shell/apps.py @@ -0,0 +1,10 @@ +"""This file contains the configuration of the shell app.""" + +from django.apps import AppConfig + + +class ShellConfig(AppConfig): + """Configuration for the shell app.""" + + default_auto_field = "django.db.models.BigAutoField" + name = "shell" diff --git a/shell/management/commands/__init__.py b/shell/management/commands/__init__.py new file mode 100644 index 0000000..fc1e437 --- /dev/null +++ b/shell/management/commands/__init__.py @@ -0,0 +1 @@ +"""Overrides the default Django management command to add a custom command.""" diff --git a/shell/management/commands/shell.py b/shell/management/commands/shell.py new file mode 100644 index 0000000..c4ba3b5 --- /dev/null +++ b/shell/management/commands/shell.py @@ -0,0 +1,17 @@ +"""Python 3.13 REPL support using the unsupported _pyrepl module.""" + +from typing import ClassVar + +from django.core.management.commands.shell import Command as BaseShellCommand + + +class Command(BaseShellCommand): + """Custom shell command to support the pyrepl shell.""" + + shells: ClassVar = ["ipython", "bpython", "pyrepl", "python"] + + def pyrepl(self, _) -> None: # noqa: ANN001 + """Start a Python 3.13 REPL using the _pyrepl module.""" + from _pyrepl.main import interactive_console + + interactive_console() diff --git a/shell/migrations/__init__.py b/shell/migrations/__init__.py new file mode 100644 index 0000000..e69de29