- Notifications
You must be signed in to change notification settings - Fork5.7k
Bump APS & Deprecatepytz
Support#4582
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
8c02b05
fcccd32
84c93bb
6e37a38
5cc7da8
1945ce7
e846251
0747587
37dfdf8
ad4d460
5008606
1f8124f
9cabf0e
92851a4
ebb71ab
a98bc65
f992b7e
1bb8ffc
b085b38
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Bibo-Joshi marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -23,14 +23,14 @@ | ||
from typing import TYPE_CHECKING, Any, Generic, Optional, Union, cast, overload | ||
try: | ||
from apscheduler.executors.asyncio import AsyncIOExecutor | ||
from apscheduler.schedulers.asyncio import AsyncIOScheduler | ||
APS_AVAILABLE = True | ||
except ImportError: | ||
APS_AVAILABLE = False | ||
from telegram._utils.datetime import UTC, localize | ||
from telegram._utils.logging import get_logger | ||
from telegram._utils.repr import build_repr_with_selected_attrs | ||
from telegram._utils.types import JSONDict | ||
@@ -155,13 +155,13 @@ def scheduler_configuration(self) -> JSONDict: | ||
dict[:obj:`str`, :obj:`object`]: The configuration values as dictionary. | ||
""" | ||
timezone:dtm.tzinfo =UTC | ||
if ( | ||
self._application | ||
and isinstance(self.application.bot, ExtBot) | ||
and self.application.bot.defaults | ||
): | ||
timezone = self.application.bot.defaults.tzinfo orUTC | ||
return { | ||
"timezone": timezone, | ||
@@ -197,8 +197,10 @@ def _parse_time_input( | ||
dtm.datetime.now(tz=time.tzinfo or self.scheduler.timezone).date(), time | ||
) | ||
if date_time.tzinfo is None: | ||
# dtm.combine uses the tzinfo of `time`, which might be None, so we still have | ||
# to localize it | ||
date_time = localize(date_time, self.scheduler.timezone) | ||
Bibo-Joshi marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if shift_day and date_time <= dtm.datetime.now(UTC): | ||
date_time += dtm.timedelta(days=1) | ||
return date_time | ||
return time | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,6 +21,7 @@ | ||
import functools | ||
import inspect | ||
import re | ||
import zoneinfo | ||
from collections.abc import Collection, Iterable | ||
from typing import Any, Callable, Optional | ||
@@ -40,15 +41,11 @@ | ||
Sticker, | ||
TelegramObject, | ||
) | ||
from telegram._utils.datetime import to_timestamp | ||
from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue | ||
from telegram.constants import InputMediaType | ||
from telegram.ext import Defaults, ExtBot | ||
from telegram.request import RequestData | ||
FORWARD_REF_PATTERN = re.compile(r"ForwardRef\('(?P<class_name>\w+)'\)") | ||
""" A pattern to find a class name in a ForwardRef typing annotation. | ||
@@ -344,10 +341,10 @@ def build_kwargs( | ||
# Some special casing for methods that have "exactly one of the optionals" type args | ||
elif name in ["location", "contact", "venue", "inline_message_id"]: | ||
kws[name] = True | ||
elif name.endswith("_date"): | ||
harshil21 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if manually_passed_value not in [None, DEFAULT_NONE]: | ||
# Europe/Berlin | ||
kws[name] = dtm.datetime(2000, 1, 1, 0, tzinfo=zoneinfo.ZoneInfo("Europe/Berlin")) | ||
else: | ||
# naive UTC | ||
kws[name] = dtm.datetime(2000, 1, 1, 0) | ||
@@ -395,6 +392,15 @@ def make_assertion_for_link_preview_options( | ||
) | ||
_EUROPE_BERLIN_TS = to_timestamp( | ||
dtm.datetime(2000, 1, 1, 0, tzinfo=zoneinfo.ZoneInfo("Europe/Berlin")) | ||
) | ||
_UTC_TS = to_timestamp(dtm.datetime(2000, 1, 1, 0), tzinfo=zoneinfo.ZoneInfo("UTC")) | ||
_AMERICA_NEW_YORK_TS = to_timestamp( | ||
dtm.datetime(2000, 1, 1, 0, tzinfo=zoneinfo.ZoneInfo("America/New_York")) | ||
) | ||
async def make_assertion( | ||
url, | ||
request_data: RequestData, | ||
@@ -530,14 +536,16 @@ def check_input_media(m: dict): | ||
) | ||
# Check datetime conversion | ||
date_keys = [key for key in data if key.endswith("_date")] | ||
for key in date_keys: | ||
date_param = data.pop(key) | ||
if date_param: | ||
if manual_value_expected and date_param != _EUROPE_BERLIN_TS: | ||
pytest.fail(f"Non-naive `{key}` should have been interpreted as Europe/Berlin.") | ||
if not any((manually_passed_value, expected_defaults_value)) and date_param != _UTC_TS: | ||
pytest.fail(f"Naive `{key}` should have been interpreted as UTC") | ||
if default_value_expected and date_param != _AMERICA_NEW_YORK_TS: | ||
pytest.fail(f"Naive `{key}` should have been interpreted as America/New_York") | ||
if method_name in ["get_file", "get_small_file", "get_big_file"]: | ||
# This is here mainly for PassportFile.get_file, which calls .set_credentials on the | ||
@@ -596,7 +604,7 @@ async def check_defaults_handling( | ||
defaults_no_custom_defaults = Defaults() | ||
kwargs = {kwarg: "custom_default" for kwarg in inspect.signature(Defaults).parameters} | ||
kwargs["tzinfo"] =zoneinfo.ZoneInfo("America/New_York") | ||
kwargs.pop("disable_web_page_preview") # mutually exclusive with link_preview_options | ||
kwargs.pop("quote") # mutually exclusive with do_quote | ||
kwargs["link_preview_options"] = LinkPreviewOptions( | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.