Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed deprecated warning message in new major version #4206

Merged
merged 3 commits into from Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions telegram/ext/_jobqueue.py
Expand Up @@ -33,7 +33,6 @@

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

Expand Down Expand Up @@ -587,13 +586,6 @@ async def callback(context: CallbackContext)
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 = {}

Expand Down
24 changes: 1 addition & 23 deletions tests/ext/test_jobqueue.py
Expand Up @@ -26,7 +26,6 @@
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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -375,20 +369,8 @@ async def test_run_daily(self, job_queue):
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
Expand All @@ -400,10 +382,6 @@ async def test_run_daily_days_of_week(self, job_queue, recwarn, weekday):
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)
Expand Down