Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15.0-beta.2']
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- python-version: '3.14t'
Expand Down
9 changes: 9 additions & 0 deletions changes/unreleased/5259.iZALQbcHZUBRwuvxwMLpf4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
other = """Support Python 3.15 Beta

* Python 3.15 free threading is not fully supported yet, as the optional dependency ``cryptography`` is not yet compatible with it.

"""
[[pull_requests]]
uid = "5259"
author_uids = ["harshil21"]
closes_threads = ["5231"]
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [
"httpx >=0.27,<0.29",
Expand Down
27 changes: 14 additions & 13 deletions src/telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,19 +343,7 @@
"warnings",
)

from telegram._inputchecklist import InputChecklist, InputChecklistTask
from telegram._payment.stars.staramount import StarAmount
from telegram._payment.stars.startransactions import StarTransaction, StarTransactions
from telegram._payment.stars.transactionpartner import (
TransactionPartner,
TransactionPartnerAffiliateProgram,
TransactionPartnerChat,
TransactionPartnerFragment,
TransactionPartnerOther,
TransactionPartnerTelegramAds,
TransactionPartnerTelegramApi,
TransactionPartnerUser,
)
__lazy_modules__: list[str] = ["constants", "error", "helpers", "request", "warnings"]

from . import _version, constants, error, helpers, request, warnings
from ._birthdate import Birthdate
Expand Down Expand Up @@ -523,6 +511,7 @@
from ._inline.inputtextmessagecontent import InputTextMessageContent
from ._inline.inputvenuemessagecontent import InputVenueMessageContent
from ._inline.preparedinlinemessage import PreparedInlineMessage
from ._inputchecklist import InputChecklist, InputChecklistTask
from ._keyboardbutton import KeyboardButton
from ._keyboardbuttonpolltype import KeyboardButtonPollType
from ._keyboardbuttonrequest import (
Expand Down Expand Up @@ -596,6 +585,18 @@
RevenueWithdrawalStatePending,
RevenueWithdrawalStateSucceeded,
)
from ._payment.stars.staramount import StarAmount
from ._payment.stars.startransactions import StarTransaction, StarTransactions
from ._payment.stars.transactionpartner import (
TransactionPartner,
TransactionPartnerAffiliateProgram,
TransactionPartnerChat,
TransactionPartnerFragment,
TransactionPartnerOther,
TransactionPartnerTelegramAds,
TransactionPartnerTelegramApi,
TransactionPartnerUser,
)
from ._payment.successfulpayment import SuccessfulPayment
from ._poll import (
InputPollOption,
Expand Down
8 changes: 8 additions & 0 deletions src/telegram/ext/_utils/trackingdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
the changelog.
"""

import sys
from collections import UserDict
from collections.abc import Mapping
from typing import Final, Generic, TypeVar
Expand Down Expand Up @@ -111,6 +112,13 @@ def pop( # type: ignore[override]
return super().pop(key)
return super().pop(key, default)

# Python 3.15 added a popitem() to UserDict, which does LIFO instead of the FIFO behaviour
# of MutableMapping.popitem(). So we keep it consistent across versions by overriding here.
if sys.version_info >= (3, 15):

def popitem(self) -> tuple[_KT, _VT]:
return super(UserDict, self).popitem()

def clear(self) -> None:
self.__track_write(set(super().keys()))
super().clear()
Expand Down
8 changes: 7 additions & 1 deletion tests/ext/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,13 @@ def test_filters_document_type(self, update):
assert not filters.Document.AUDIO.check_update(update)

update.message.document.mime_type = "application/octet-stream"
assert filters.Document.EXE.check_update(update)
# Python 3.15 changes the "exe" mime type to application/vnd.microsoft.portable-executable
if int(platform.python_version_tuple()[1]) <= 14:
assert filters.Document.EXE.check_update(update)
else:
assert not filters.Document.EXE.check_update(update)
update.message.document.mime_type = "application/vnd.microsoft.portable-executable"
assert filters.Document.EXE.check_update(update)
assert filters.Document.APPLICATION.check_update(update)
assert not filters.Document.DOCX.check_update(update)
assert not filters.Document.AUDIO.check_update(update)
Expand Down
1 change: 1 addition & 0 deletions tests/test_official/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def cached_type_hints(obj: Any, is_class: bool) -> dict[str, Any]:
@functools.cache
def resolve_forward_refs_in_type(obj: type) -> type:
"""Resolves forward references in a type hint."""
# TODO: Refactor test_official to properly use annotationlib
return _eval_type(obj, localns=tg_objects, globalns=None)


Expand Down
4 changes: 4 additions & 0 deletions tests/test_official/test_official.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
# 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 inspect
import platform
from typing import TYPE_CHECKING

import pytest

if platform.python_version_tuple() >= ("3", "15"):
pytest.skip("Running on Python version > 3.15 is not supported yet!", allow_module_level=True)

import telegram
from tests.auxil.envvars import RUN_TEST_OFFICIAL
from tests.test_official.arg_type_checker import (
Expand Down
Loading
Loading