aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/utils/snekbox/_cog.py5
-rw-r--r--bot/exts/utils/snekbox/_constants.py4
-rw-r--r--bot/exts/utils/snekbox/_eval.py5
-rw-r--r--tests/bot/exts/utils/snekbox/test_snekbox.py6
4 files changed, 11 insertions, 9 deletions
diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py
index 5fb160a5f..b6825faa7 100644
--- a/bot/exts/utils/snekbox/_cog.py
+++ b/bot/exts/utils/snekbox/_cog.py
@@ -20,6 +20,7 @@ from bot.exts.filtering._filter_lists.extension import TXT_LIKE_FILES
from bot.exts.help_channels._channel import is_help_forum_post
from bot.exts.utils.snekbox._constants import (
ANSI_REGEX,
+ DEFAULT_PYTHON_VERSION,
ESCAPE_REGEX,
MAX_OUTPUT_BLOCK_CHARS,
MAX_OUTPUT_BLOCK_LINES,
@@ -602,7 +603,7 @@ class Snekbox(Cog):
) -> None:
"""Run Python code and get the results."""
code: list[str]
- python_version = python_version or get_args(SupportedPythonVersions)[0]
+ python_version = python_version or DEFAULT_PYTHON_VERSION
job = EvalJob.from_code("\n".join(code)).as_version(python_version)
await self.run_job(ctx, job)
@@ -643,7 +644,7 @@ class Snekbox(Cog):
) -> None:
"""Profile Python Code to find execution time."""
code: list[str]
- python_version = python_version or get_args(SupportedPythonVersions)[0]
+ python_version = python_version or DEFAULT_PYTHON_VERSION
args = self.prepare_timeit_input(code)
job = EvalJob(args, version=python_version, name="timeit")
diff --git a/bot/exts/utils/snekbox/_constants.py b/bot/exts/utils/snekbox/_constants.py
index efcb47c33..09f94170b 100644
--- a/bot/exts/utils/snekbox/_constants.py
+++ b/bot/exts/utils/snekbox/_constants.py
@@ -19,4 +19,6 @@ SNEKBOX_ROLES = (Roles.helpers, Roles.moderators, Roles.admins, Roles.owners, Ro
REDO_EMOJI = "\U0001f501" # :repeat:
REDO_TIMEOUT = 30
-SupportedPythonVersions = Literal["3.14", "3.13", "3.13t"]
+SupportedPythonVersions = Literal["3.13", "3.13t", "3.14"]
+
+DEFAULT_PYTHON_VERSION: SupportedPythonVersions = "3.14"
diff --git a/bot/exts/utils/snekbox/_eval.py b/bot/exts/utils/snekbox/_eval.py
index 73f843bc0..6240d0cc6 100644
--- a/bot/exts/utils/snekbox/_eval.py
+++ b/bot/exts/utils/snekbox/_eval.py
@@ -3,12 +3,11 @@ from __future__ import annotations
import contextlib
from dataclasses import dataclass, field
from signal import Signals
-from typing import get_args
from discord.utils import escape_markdown, escape_mentions
from bot.constants import Emojis
-from bot.exts.utils.snekbox._constants import SupportedPythonVersions
+from bot.exts.utils.snekbox._constants import DEFAULT_PYTHON_VERSION, SupportedPythonVersions
from bot.exts.utils.snekbox._io import FILE_COUNT_LIMIT, FILE_SIZE_LIMIT, FileAttachment, sizeof_fmt
from bot.log import get_logger
@@ -24,7 +23,7 @@ class EvalJob:
args: list[str]
files: list[FileAttachment] = field(default_factory=list)
name: str = "eval"
- version: SupportedPythonVersions = get_args(SupportedPythonVersions)[0]
+ version: SupportedPythonVersions = DEFAULT_PYTHON_VERSION
@classmethod
def from_code(cls, code: str, path: str = "main.py") -> EvalJob:
diff --git a/tests/bot/exts/utils/snekbox/test_snekbox.py b/tests/bot/exts/utils/snekbox/test_snekbox.py
index 69262bf61..7a0a70385 100644
--- a/tests/bot/exts/utils/snekbox/test_snekbox.py
+++ b/tests/bot/exts/utils/snekbox/test_snekbox.py
@@ -1,7 +1,6 @@
import asyncio
import unittest
from base64 import b64encode
-from typing import get_args
from unittest.mock import AsyncMock, MagicMock, Mock, call, create_autospec, patch
from discord import AllowedMentions
@@ -11,7 +10,8 @@ from pydis_core.utils.paste_service import MAX_PASTE_SIZE
from bot import constants
from bot.errors import LockedResourceError
from bot.exts.utils import snekbox
-from bot.exts.utils.snekbox import EvalJob, EvalResult, Snekbox, SupportedPythonVersions
+from bot.exts.utils.snekbox import EvalJob, EvalResult, Snekbox
+from bot.exts.utils.snekbox._constants import DEFAULT_PYTHON_VERSION
from bot.exts.utils.snekbox._io import FileAttachment
from tests.helpers import MockBot, MockContext, MockMember, MockMessage, MockReaction, MockUser
@@ -22,7 +22,7 @@ class SnekboxTests(unittest.IsolatedAsyncioTestCase):
self.bot = MockBot()
self.cog = Snekbox(bot=self.bot)
self.job = EvalJob.from_code("import random")
- self.default_version = get_args(SupportedPythonVersions)[0]
+ self.default_version = DEFAULT_PYTHON_VERSION
@staticmethod
def code_args(code: str) -> tuple[EvalJob]: