From 42b68f1a708250f7c495ca968a0196f5cca999ea Mon Sep 17 00:00:00 2001 From: Nano Date: Sun, 14 Apr 2024 20:14:45 +0800 Subject: [PATCH] Remove Deprecation Warning in `JobQueue.run_daily` (#4206) --- telegram/ext/_jobqueue.py | 8 -------- tests/ext/test_jobqueue.py | 24 +----------------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/telegram/ext/_jobqueue.py b/telegram/ext/_jobqueue.py index 940a80bb4..1229659f6 100644 --- a/telegram/ext/_jobqueue.py +++ b/telegram/ext/_jobqueue.py @@ -33,7 +33,6 @@ except ImportError: from telegram._utils.repr import build_repr_with_selected_attrs from telegram._utils.types import JSONDict -from telegram._utils.warnings import warn from telegram.ext._extbot import ExtBot from telegram.ext._utils.types import CCT, JobCallback @@ -587,13 +586,6 @@ class JobQueue(Generic[CCT]): queue. """ - # TODO: After v20.0, we should remove this warning. - if days != tuple(range(7)): # checks if user passed a custom value - warn( - "Prior to v20.0 the `days` parameter was not aligned to that of cron's weekday " - "scheme. We recommend double checking if the passed value is correct.", - stacklevel=2, - ) if not job_kwargs: job_kwargs = {} diff --git a/tests/ext/test_jobqueue.py b/tests/ext/test_jobqueue.py index 458fc4cc4..0a3723763 100644 --- a/tests/ext/test_jobqueue.py +++ b/tests/ext/test_jobqueue.py @@ -26,7 +26,6 @@ import time import pytest from telegram.ext import ApplicationBuilder, CallbackContext, ContextTypes, Defaults, Job, JobQueue -from telegram.warnings import PTBUserWarning from tests.auxil.envvars import GITHUB_ACTION, TEST_WITH_OPT_DEPS from tests.auxil.pytest_classes import make_bot from tests.auxil.slots import mro_slots @@ -80,11 +79,6 @@ class TestJobQueue: job_time = 0 received_error = None - expected_warning = ( - "Prior to v20.0 the `days` parameter was not aligned to that of cron's weekday scheme." - " We recommend double checking if the passed value is correct." - ) - async def test_repr(self, app): jq = JobQueue() jq.set_application(app) @@ -375,20 +369,8 @@ class TestJobQueue: scheduled_time = job_queue.jobs()[0].next_t.timestamp() assert scheduled_time == pytest.approx(expected_reschedule_time) - async def test_run_daily_warning(self, job_queue, recwarn): - delta, now = 1, dtm.datetime.now(UTC) - time_of_day = (now + dtm.timedelta(seconds=delta)).time() - - job_queue.run_daily(self.job_run_once, time_of_day) - assert len(recwarn) == 0 - job_queue.run_daily(self.job_run_once, time_of_day, days=(0, 1, 2, 3)) - assert len(recwarn) == 1 - assert str(recwarn[0].message) == self.expected_warning - assert recwarn[0].category is PTBUserWarning - assert recwarn[0].filename == __file__, "wrong stacklevel" - @pytest.mark.parametrize("weekday", [0, 1, 2, 3, 4, 5, 6]) - async def test_run_daily_days_of_week(self, job_queue, recwarn, weekday): + async def test_run_daily_days_of_week(self, job_queue, weekday): delta, now = 1, dtm.datetime.now(UTC) time_of_day = (now + dtm.timedelta(seconds=delta)).time() # offset in days until next weekday @@ -400,10 +382,6 @@ class TestJobQueue: await asyncio.sleep(delta + 0.1) scheduled_time = job_queue.jobs()[0].next_t.timestamp() assert scheduled_time == pytest.approx(expected_reschedule_time) - assert len(recwarn) == 1 - assert str(recwarn[0].message) == self.expected_warning - assert recwarn[0].category is PTBUserWarning - assert recwarn[0].filename == __file__, "wrong stacklevel" async def test_run_monthly(self, job_queue, timezone): delta, now = 1, dtm.datetime.now(timezone)