Skip to content

Commit e27e714

Browse files
committed
Don't hardcode which python version to use in timeit command
1 parent f971081 commit e27e714

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

bot/exts/utils/snekbox/_cog.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,26 @@ async def eval_command(
613613
job = EvalJob.from_code("\n".join(code)).as_version(python_version)
614614
await self.run_job(ctx, job)
615615

616-
@command(name="timeit", aliases=("ti",), usage="[python_version] [setup_code] <code, ...>")
616+
@command(
617+
name="timeit",
618+
aliases=("ti",),
619+
usage="[python_version] [setup_code] <code, ...>",
620+
help=f"""
621+
Profile Python code to find execution time.
622+
623+
This command supports multiple lines of code, including formatted code blocks.
624+
Code can be re-evaluated by editing the original message within 10 seconds and
625+
clicking the reaction that subsequently appears.
626+
627+
If multiple formatted codeblocks are provided, the first one will be the setup code,
628+
which will not be timed. The remaining codeblocks will be joined together and timed.
629+
630+
The currently supported versions are {", ".join(get_args(SupportedPythonVersions))}.
631+
632+
We've done our best to make this sandboxed, but do let us know if you manage to find an
633+
issue with it!
634+
"""
635+
)
617636
@guild_only()
618637
@redirect_output(
619638
destination_channel=Channels.bot_commands,
@@ -629,23 +648,9 @@ async def timeit_command(
629648
*,
630649
code: CodeblockConverter
631650
) -> None:
632-
"""
633-
Profile Python Code to find execution time.
634-
635-
This command supports multiple lines of code, including code wrapped inside a formatted code
636-
block. Code can be re-evaluated by editing the original message within 10 seconds and
637-
clicking the reaction that subsequently appears.
638-
639-
If multiple formatted codeblocks are provided, the first one will be the setup code, which will
640-
not be timed. The remaining codeblocks will be joined together and timed.
641-
642-
The currently supported verisons are 3.13, 3.13t, and 3.14.
643-
644-
We've done our best to make this sandboxed, but do let us know if you manage to find an
645-
issue with it!
646-
"""
651+
"""Profile Python Code to find execution time."""
647652
code: list[str]
648-
python_version = python_version or "3.13"
653+
python_version = python_version or get_args(SupportedPythonVersions)[0]
649654
args = self.prepare_timeit_input(code)
650655
job = EvalJob(args, version=python_version, name="timeit")
651656

0 commit comments

Comments
 (0)