Lower Python requirement to 3.10 instead of 3.13

This commit is contained in:
2025-01-30 02:44:12 +01:00
parent 9a629ce773
commit 22b90fdcee
3 changed files with 22 additions and 17 deletions

13
noxfile.py Normal file
View File

@ -0,0 +1,13 @@
from __future__ import annotations
import nox # type: ignore[import]
nox.options.default_venv_backend = "uv"
@nox.session(python=["3.10", "3.11", "3.12", "3.13"])
def tests(session: nox.Session) -> None:
"""Run the test suite."""
session.install(".")
session.install("pytest")
session.run("pytest")

View File

@ -1,13 +1,9 @@
# TODO(TheLovinator): Add GitHub Actions workflow for installing and running with Poetry
# TODO(TheLovinator): Add GitHub Actions workflow for installing and running with uv
# TODO(TheLovinator): Test bot on linux/windows/macOS with different Python versions and architectures
[project] [project]
name = "discord-reminder-bot" name = "discord-reminder-bot"
version = "2.0.0" version = "2.0.0"
description = "Discord bot that allows you to set date, cron and interval reminders." description = "Discord bot that allows you to set date, cron and interval reminders."
readme = "README.md" readme = "README.md"
requires-python = ">=3.13" requires-python = ">=3.10"
dependencies = [ dependencies = [
# The Discord bot library uses discord.py # The Discord bot library uses discord.py
# legacy-cgi and audioop-lts are because Python 3.13 removed cgi module and audioop module # legacy-cgi and audioop-lts are because Python 3.13 removed cgi module and audioop module
@ -36,7 +32,7 @@ dependencies = [
] ]
[dependency-groups] [dependency-groups]
dev = ["pytest", "ruff", "pre-commit", "pytest-asyncio", "freezegun"] dev = ["pytest"]
[tool.poetry] [tool.poetry]
name = "discord-reminder-bot" name = "discord-reminder-bot"
@ -49,7 +45,7 @@ license = "GPL-3.0-or-later"
bot = "discord_reminder_bot.main:start" bot = "discord_reminder_bot.main:start"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.13" python = "^3.10"
# https://github.com/agronholm/apscheduler # https://github.com/agronholm/apscheduler
# https://github.com/sqlalchemy/sqlalchemy # https://github.com/sqlalchemy/sqlalchemy
@ -88,10 +84,6 @@ loguru = {version = ">=0.7.3,<1.0.0"}
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = "*" pytest = "*"
pre-commit = "*"
ruff = "*"
pytest-asyncio = "*"
freezegun = "*"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]

View File

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from datetime import UTC, datetime, timedelta from datetime import datetime, timedelta, timezone
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
@ -14,22 +14,22 @@ if TYPE_CHECKING:
def test_calc_time() -> None: def test_calc_time() -> None:
"""Test the calc_time function with various datetime inputs.""" """Test the calc_time function with various datetime inputs."""
test_datetime: datetime = datetime(2023, 10, 1, 12, 0, 0, tzinfo=UTC) test_datetime: datetime = datetime(2023, 10, 1, 12, 0, 0, tzinfo=timezone.utc)
expected_timestamp: str = f"<t:{int(test_datetime.timestamp())}:R>" expected_timestamp: str = f"<t:{int(test_datetime.timestamp())}:R>"
assert_msg = f"Expected {expected_timestamp}, got {calc_time(test_datetime)}" assert_msg = f"Expected {expected_timestamp}, got {calc_time(test_datetime)}"
assert calc_time(test_datetime) == expected_timestamp, assert_msg assert calc_time(test_datetime) == expected_timestamp, assert_msg
now: datetime = datetime.now(tz=UTC) now: datetime = datetime.now(tz=timezone.utc)
expected_timestamp_now: str = f"<t:{int(now.timestamp())}:R>" expected_timestamp_now: str = f"<t:{int(now.timestamp())}:R>"
assert_msg = f"Expected {expected_timestamp_now}, got {calc_time(now)}" assert_msg = f"Expected {expected_timestamp_now}, got {calc_time(now)}"
assert calc_time(now) == expected_timestamp_now, assert_msg assert calc_time(now) == expected_timestamp_now, assert_msg
past_datetime: datetime = datetime(2000, 1, 1, 0, 0, 0, tzinfo=UTC) past_datetime: datetime = datetime(2000, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
expected_timestamp_past: str = f"<t:{int(past_datetime.timestamp())}:R>" expected_timestamp_past: str = f"<t:{int(past_datetime.timestamp())}:R>"
assert_msg = f"Expected {expected_timestamp_past}, got {calc_time(past_datetime)}" assert_msg = f"Expected {expected_timestamp_past}, got {calc_time(past_datetime)}"
assert calc_time(past_datetime) == expected_timestamp_past, assert_msg assert calc_time(past_datetime) == expected_timestamp_past, assert_msg
future_datetime: datetime = datetime(2100, 1, 1, 0, 0, 0, tzinfo=UTC) future_datetime: datetime = datetime(2100, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
expected_timestamp_future: str = f"<t:{int(future_datetime.timestamp())}:R>" expected_timestamp_future: str = f"<t:{int(future_datetime.timestamp())}:R>"
assert_msg: str = f"Expected {expected_timestamp_future}, got {calc_time(future_datetime)}" assert_msg: str = f"Expected {expected_timestamp_future}, got {calc_time(future_datetime)}"
assert calc_time(future_datetime) == expected_timestamp_future, assert_msg assert calc_time(future_datetime) == expected_timestamp_future, assert_msg
@ -69,7 +69,7 @@ def test_calculate() -> None:
scheduler.start() scheduler.start()
# Create a job with a DateTrigger # Create a job with a DateTrigger
run_date = datetime(2270, 10, 1, 12, 0, 0, tzinfo=UTC) run_date = datetime(2270, 10, 1, 12, 0, 0, tzinfo=timezone.utc)
job: Job = scheduler.add_job(lambda: None, trigger=DateTrigger(run_date=run_date), id="test_job", name="Test Job") job: Job = scheduler.add_job(lambda: None, trigger=DateTrigger(run_date=run_date), id="test_job", name="Test Job")
expected_output = "<t:9490737600:R>" expected_output = "<t:9490737600:R>"