Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unify datetime import in all files#4605

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

Merged
Bibo-Joshi merged 16 commits intopython-telegram-bot:masterfromUSB-CI3715:master
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
6f97f22
Refactor datetime imports to use alias 'dtm' for consistency across m…
cuevasrjaDec 9, 2024
58cdc0f
Refactor datetime imports (#2)
Migueldsc12Dec 13, 2024
f5233a4
Refactorización de importaciones de datetime para mantener la coheren…
Jeam-zxDec 13, 2024
84752f0
Refactor: unify datetime imports (#3)
henryg311Dec 13, 2024
fd9cbb6
Refactor datetime imports to use alias 'dtm' for consistency in test …
AnyaMarcanitoDec 13, 2024
543a6da
Add new collaborators
cuevasrjaDec 13, 2024
af066af
Refactor: use dtm.datetime.utcnow() for consistency in message timest…
cuevasrjaDec 13, 2024
a39432b
Refactor: update type checks for last_error_date and last_synchroniza…
cuevasrjaDec 13, 2024
c75b2d1
Refactor: update datetime imports in test_birthdate.py to use alias '…
cuevasrjaDec 13, 2024
c45c0b0
Refactor: update exclusion of 'dtm' in TestConstantsWithoutRequest to…
cuevasrjaDec 13, 2024
3ee6a3d
Refactor: exclude 'dtm' from filter keys in TestFilters for improved …
cuevasrjaDec 13, 2024
e32c94d
Update datetime imports to use alias 'dtm' for consistency in test_bu…
Jeam-zxDec 13, 2024
2613ab2
Merge branch 'master' into master
Jeam-zxDec 13, 2024
deaa1c3
Refactor: update datetime imports to use alias 'dtm' in _birthdate.py…
cuevasrjaDec 14, 2024
dda1e7c
Revert "Merge branch 'master' into master"
cuevasrjaDec 14, 2024
ac111d4
Reapply "Merge branch 'master' into master"
cuevasrjaDec 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletionsAUTHORS.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Ambro17 <https://github.com/Ambro17>`_
- `Andrej Zhilenkov <https://github.com/Andrej730>`_
- `Anton Tagunov <https://github.com/anton-tagunov>`_
- `Anya Marcano <https://github.com/AnyaMarcanito>`
- `Avanatiker <https://github.com/Avanatiker>`_
- `Balduro <https://github.com/Balduro>`_
- `Bibo-Joshi <https://github.com/Bibo-Joshi>`_
Expand DownExpand Up@@ -58,12 +59,14 @@ The following wonderful people contributed directly or indirectly to this projec
- `gamgi <https://github.com/gamgi>`_
- `Gauthamram Ravichandran <https://github.com/GauthamramRavichandran>`_
- `Harshil <https://github.com/harshil21>`_
- `Henry Galue <https://github.com/henryg311>`
- `Hugo Damer <https://github.com/HakimusGIT>`_
- `ihoru <https://github.com/ihoru>`_
- `Iulian Onofrei <https://github.com/revolter>`_
- `Jainam Oswal <https://github.com/jainamoswal>`_
- `Jasmin Bom <https://github.com/jsmnbom>`_
- `JASON0916 <https://github.com/JASON0916>`_
- `Jeamhowards Montiel <https://github.com/Jeam-zx>`
- `jeffffc <https://github.com/jeffffc>`_
- `Jelle Besseling <https://github.com/pingiun>`_
- `jh0ker <https://github.com/jh0ker>`_
Expand All@@ -72,6 +75,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Joscha Götzer <https://github.com/Rostgnom>`_
- `jossalgon <https://github.com/jossalgon>`_
- `JRoot3D <https://github.com/JRoot3D>`_
- `Juan Cuevas <https://github.com/cuevasrja>`
- `kenjitagawa <https://github.com/kenjitagawa>`_
- `kennethcheo <https://github.com/kennethcheo>`_
- `Kirill Vasin <https://github.com/vasinkd>`_
Expand All@@ -87,6 +91,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Michael Dix <https://github.com/Eisberge>`_
- `Michael Elovskikh <https://github.com/wronglink>`_
- `Miguel C. R. <https://github.com/MiguelX413>`_
- `Miguel Salomon <https://github.com/Migueldsc12>`
- `miles <https://github.com/miles170>`_
- `Mischa Krüger <https://github.com/Makman2>`_
- `Mohd Yusuf <https://github.com/mohdyusuf2312>`_
Expand Down
4 changes: 2 additions & 2 deletionsdocs/auxil/tg_const_role.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import datetime
import datetime as dtm
from enum import Enum

from docutils.nodes import Element
Expand DownExpand Up@@ -75,7 +75,7 @@ def process_link(
):
return str(value), target
if (
isinstance(value,datetime.datetime)
isinstance(value,dtm.datetime)
and value == telegram.constants.ZERO_DATE
and target in ("telegram.constants.ZERO_DATE",)
):
Expand Down
6 changes: 3 additions & 3 deletionstelegram/_birthdate.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Birthday."""
from datetimeimport date
import datetimeas dtm
from typing import Optional

from telegram._telegramobject import TelegramObject
Expand DownExpand Up@@ -70,7 +70,7 @@ def __init__(

self._freeze()

def to_date(self, year: Optional[int] = None) -> date:
def to_date(self, year: Optional[int] = None) ->dtm.date:
"""Return the birthdate as a date object.

.. versionchanged:: 21.2
Expand All@@ -89,4 +89,4 @@ def to_date(self, year: Optional[int] = None) -> date:
"The `year` argument is required if the `year` attribute was not present."
)

return date(year or self.year, self.month, self.day) # type: ignore[arg-type]
returndtm.date(year or self.year, self.month, self.day) # type: ignore[arg-type]
18 changes: 9 additions & 9 deletionstelegram/_bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,9 +22,9 @@
import asyncio
import contextlib
import copy
import datetime as dtm
import pickle
from collections.abc import Sequence
from datetime import datetime, timedelta
from types import TracebackType
from typing import (
TYPE_CHECKING,
Expand DownExpand Up@@ -3815,7 +3815,7 @@ async def ban_chat_member(
self,
chat_id: Union[str, int],
user_id: int,
until_date: Optional[Union[int, datetime]] = None,
until_date: Optional[Union[int,dtm.datetime]] = None,
revoke_messages: Optional[bool] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -5451,7 +5451,7 @@ async def restrict_chat_member(
chat_id: Union[str, int],
user_id: int,
permissions: ChatPermissions,
until_date: Optional[Union[int, datetime]] = None,
until_date: Optional[Union[int,dtm.datetime]] = None,
use_independent_chat_permissions: Optional[bool] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -5788,7 +5788,7 @@ async def export_chat_invite_link(
async def create_chat_invite_link(
self,
chat_id: Union[str, int],
expire_date: Optional[Union[int, datetime]] = None,
expire_date: Optional[Union[int,dtm.datetime]] = None,
member_limit: Optional[int] = None,
name: Optional[str] = None,
creates_join_request: Optional[bool] = None,
Expand DownExpand Up@@ -5864,7 +5864,7 @@ async def edit_chat_invite_link(
self,
chat_id: Union[str, int],
invite_link: Union[str, "ChatInviteLink"],
expire_date: Optional[Union[int, datetime]] = None,
expire_date: Optional[Union[int,dtm.datetime]] = None,
member_limit: Optional[int] = None,
name: Optional[str] = None,
creates_join_request: Optional[bool] = None,
Expand DownExpand Up@@ -6233,7 +6233,7 @@ async def set_user_emoji_status(
self,
user_id: int,
emoji_status_custom_emoji_id: Optional[str] = None,
emoji_status_expiration_date: Optional[Union[int, datetime]] = None,
emoji_status_expiration_date: Optional[Union[int,dtm.datetime]] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -7159,7 +7159,7 @@ async def send_poll(
explanation: Optional[str] = None,
explanation_parse_mode: ODVInput[str] = DEFAULT_NONE,
open_period: Optional[int] = None,
close_date: Optional[Union[int, datetime]] = None,
close_date: Optional[Union[int,dtm.datetime]] = None,
explanation_entities: Optional[Sequence["MessageEntity"]] = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
message_thread_id: Optional[int] = None,
Expand DownExpand Up@@ -8125,7 +8125,7 @@ async def create_invoice_link(
send_phone_number_to_provider: Optional[bool] = None,
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
subscription_period: Optional[Union[int, timedelta]] = None,
subscription_period: Optional[Union[int,dtm.timedelta]] = None,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -8248,7 +8248,7 @@ async def create_invoice_link(
"send_email_to_provider": send_email_to_provider,
"subscription_period": (
subscription_period.total_seconds()
if isinstance(subscription_period, timedelta)
if isinstance(subscription_period,dtm.timedelta)
else subscription_period
),
"business_connection_id": business_connection_id,
Expand Down
7 changes: 3 additions & 4 deletionstelegram/_business.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]
"""This module contains the Telegram Business related classes."""

import datetime as dtm
from collections.abc import Sequence
from datetime import datetime
from typing import TYPE_CHECKING, Optional

from telegram._chat import Chat
Expand DownExpand Up@@ -81,7 +80,7 @@ def __init__(
id: str,
user: "User",
user_chat_id: int,
date: datetime,
date:dtm.datetime,
can_reply: bool,
is_enabled: bool,
*,
Expand All@@ -91,7 +90,7 @@ def __init__(
self.id: str = id
self.user: User = user
self.user_chat_id: int = user_chat_id
self.date: datetime = date
self.date:dtm.datetime = date
self.can_reply: bool = can_reply
self.is_enabled: bool = is_enabled

Expand Down
12 changes: 6 additions & 6 deletionstelegram/_chat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Chat."""
import datetime as dtm
from collections.abc import Sequence
from datetime import datetime
from html import escape
from typing import TYPE_CHECKING, Final, Optional, Union

Expand DownExpand Up@@ -384,7 +384,7 @@ async def ban_member(
self,
user_id: int,
revoke_messages: Optional[bool] = None,
until_date: Optional[Union[int, datetime]] = None,
until_date: Optional[Union[int,dtm.datetime]] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -656,7 +656,7 @@ async def restrict_member(
self,
user_id: int,
permissions: ChatPermissions,
until_date: Optional[Union[int, datetime]] = None,
until_date: Optional[Union[int,dtm.datetime]] = None,
use_independent_chat_permissions: Optional[bool] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -2116,7 +2116,7 @@ async def send_poll(
explanation: Optional[str] = None,
explanation_parse_mode: ODVInput[str] = DEFAULT_NONE,
open_period: Optional[int] = None,
close_date: Optional[Union[int, datetime]] = None,
close_date: Optional[Union[int,dtm.datetime]] = None,
explanation_entities: Optional[Sequence["MessageEntity"]] = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
message_thread_id: Optional[int] = None,
Expand DownExpand Up@@ -2588,7 +2588,7 @@ async def export_invite_link(

async def create_invite_link(
self,
expire_date: Optional[Union[int, datetime]] = None,
expire_date: Optional[Union[int,dtm.datetime]] = None,
member_limit: Optional[int] = None,
name: Optional[str] = None,
creates_join_request: Optional[bool] = None,
Expand DownExpand Up@@ -2632,7 +2632,7 @@ async def create_invite_link(
async def edit_invite_link(
self,
invite_link: Union[str, "ChatInviteLink"],
expire_date: Optional[Union[int, datetime]] = None,
expire_date: Optional[Union[int,dtm.datetime]] = None,
member_limit: Optional[int] = None,
name: Optional[str] = None,
creates_join_request: Optional[bool] = None,
Expand Down
15 changes: 7 additions & 8 deletionstelegram/_chatboost.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,9 +17,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram ChatBoosts."""

import datetime as dtm
from collections.abc import Sequence
from datetime import datetime
from typing import TYPE_CHECKING, Final, Optional

from telegram import constants
Expand DownExpand Up@@ -274,17 +273,17 @@ class ChatBoost(TelegramObject):
def __init__(
self,
boost_id: str,
add_date: datetime,
expiration_date: datetime,
add_date:dtm.datetime,
expiration_date:dtm.datetime,
source: ChatBoostSource,
*,
api_kwargs: Optional[JSONDict] = None,
):
super().__init__(api_kwargs=api_kwargs)

self.boost_id: str = boost_id
self.add_date: datetime = add_date
self.expiration_date: datetime = expiration_date
self.add_date:dtm.datetime = add_date
self.expiration_date:dtm.datetime = expiration_date
self.source: ChatBoostSource = source

self._id_attrs = (self.boost_id, self.add_date, self.expiration_date, self.source)
Expand DownExpand Up@@ -386,7 +385,7 @@ def __init__(
self,
chat: Chat,
boost_id: str,
remove_date: datetime,
remove_date:dtm.datetime,
source: ChatBoostSource,
*,
api_kwargs: Optional[JSONDict] = None,
Expand All@@ -395,7 +394,7 @@ def __init__(

self.chat: Chat = chat
self.boost_id: str = boost_id
self.remove_date: datetime = remove_date
self.remove_date:dtm.datetime = remove_date
self.source: ChatBoostSource = source

self._id_attrs = (self.chat, self.boost_id, self.remove_date, self.source)
Expand Down
8 changes: 5 additions & 3 deletionstelegram/_chatfullinfo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,8 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatFullInfo."""
import datetime as dtm
from collections.abc import Sequence
from datetime import datetime
from typing import TYPE_CHECKING, Optional

from telegram._birthdate import Birthdate
Expand DownExpand Up@@ -422,7 +422,7 @@ def __init__(
profile_accent_color_id: Optional[int] = None,
profile_background_custom_emoji_id: Optional[str] = None,
emoji_status_custom_emoji_id: Optional[str] = None,
emoji_status_expiration_date: Optional[datetime] = None,
emoji_status_expiration_date: Optional[dtm.datetime] = None,
bio: Optional[str] = None,
has_private_forwards: Optional[bool] = None,
has_restricted_voice_and_video_messages: Optional[bool] = None,
Expand DownExpand Up@@ -486,7 +486,9 @@ def __init__(
)
self.active_usernames: tuple[str, ...] = parse_sequence_arg(active_usernames)
self.emoji_status_custom_emoji_id: Optional[str] = emoji_status_custom_emoji_id
self.emoji_status_expiration_date: Optional[datetime] = emoji_status_expiration_date
self.emoji_status_expiration_date: Optional[dtm.datetime] = (
emoji_status_expiration_date
)
self.has_aggressive_anti_spam_enabled: Optional[bool] = (
has_aggressive_anti_spam_enabled
)
Expand Down
6 changes: 3 additions & 3 deletionstelegram/_chatinvitelink.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents an invite link for a chat."""
import datetime
import datetime as dtm
from typing import TYPE_CHECKING, Optional

from telegram._telegramobject import TelegramObject
Expand DownExpand Up@@ -139,7 +139,7 @@ def __init__(
creates_join_request: bool,
is_primary: bool,
is_revoked: bool,
expire_date: Optional[datetime.datetime] = None,
expire_date: Optional[dtm.datetime] = None,
member_limit: Optional[int] = None,
name: Optional[str] = None,
pending_join_request_count: Optional[int] = None,
Expand All@@ -157,7 +157,7 @@ def __init__(
self.is_revoked: bool = is_revoked

# Optionals
self.expire_date: Optional[datetime.datetime] = expire_date
self.expire_date: Optional[dtm.datetime] = expire_date
self.member_limit: Optional[int] = member_limit
self.name: Optional[str] = name
self.pending_join_request_count: Optional[int] = (
Expand Down
6 changes: 3 additions & 3 deletionstelegram/_chatjoinrequest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatJoinRequest."""
import datetime
import datetime as dtm
from typing import TYPE_CHECKING, Optional

from telegram._chat import Chat
Expand DownExpand Up@@ -106,7 +106,7 @@ def __init__(
self,
chat: Chat,
from_user: User,
date:datetime.datetime,
date:dtm.datetime,
user_chat_id: int,
bio: Optional[str] = None,
invite_link: Optional[ChatInviteLink] = None,
Expand All@@ -117,7 +117,7 @@ def __init__(
# Required
self.chat: Chat = chat
self.from_user: User = from_user
self.date:datetime.datetime = date
self.date:dtm.datetime = date
self.user_chat_id: int = user_chat_id

# Optionals
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp