Skip to content

Add support for Python 3.14 beta #4825

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

Merged
merged 11 commits into from
Jun 19, 2025
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
8 changes: 3 additions & 5 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14.0-beta.3']
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: False
steps:
Expand All @@ -36,7 +36,6 @@ jobs:
- name: Install dependencies
run: |
python -W ignore -m pip install --upgrade pip
python -W ignore -m pip install -U pytest-cov
python -W ignore -m pip install . --group tests

- name: Test with pytest
Expand All @@ -59,11 +58,10 @@ jobs:
TO_TEST="test_no_passport.py or test_datetime.py or test_defaults.py or test_jobqueue.py or test_applicationbuilder.py or test_ratelimiter.py or test_updater.py or test_callbackdatacache.py or test_request.py"
pytest -v --cov -k "${TO_TEST}" --junit-xml=.test_report_no_optionals_junit.xml
opt_dep_status=$?

# Test the rest
export TEST_WITH_OPT_DEPS='true'
# need to manually install pytz here, because it's no longer in the optional reqs
pip install .[all] pytz
pip install .[all]
# `-n auto --dist worksteal` uses pytest-xdist to run tests on multiple CPU
# workers. Increasing number of workers has little effect on test duration, but it seems
# to increase flakyness.
Expand Down
5 changes: 5 additions & 0 deletions changes/unreleased/4825.R7wiTzvN37KAV656s9kfnC.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
other = "Add Python 3.14 Beta To Test Matrix. *Python 3.14 is not officially supported by PTB yet!*"
[[pull_requests]]
uid = "4825"
author_uid = "harshil21"
closes_threads = []
16 changes: 14 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"httpx >=0.27,<0.29",
Expand Down Expand Up @@ -91,15 +92,15 @@ socks = [
]
webhooks = [
# tornado is rather stable, but let's not allow the next major release without prior testing
"tornado~=6.4",
"tornado~=6.5",
]

[dependency-groups]
tests = [
# required for building the wheels for releases
"build",
# For the test suite
"pytest==8.3.5",
"pytest==8.4.0",
# needed because pytest doesn't come with native support for coroutines as tests
"pytest-asyncio==0.21.2",
# xdist runs tests in parallel
Expand All @@ -111,6 +112,10 @@ tests = [
# For testing with timezones. Might not be needed on all systems, but to ensure that unit tests
# run correctly on all systems, we include it here.
"tzdata",
# We've deprecated support pytz, but we still need it for testing that it works with the library.
"pytz",
# Install coverage:
"pytest-cov"
]
docs = [
"chango~=0.4.0; python_version >= '3.12'",
Expand All @@ -123,6 +128,13 @@ docs = [
"sphinx-inline-tabs==2023.4.21",
# Temporary. See #4387
"sphinx-build-compatibility @ git+https://github.com/readthedocs/sphinx-build-compatibility.git@58aabc5f207c6c2421f23d3578adc0b14af57047",
# For python 3.14 support, we need a version of pydantic-core >= 2.35.0, since it upgrades the
# rust toolchain, required for building the project. But there isn't a version of pydantic
# which allows that pydantic-core version yet, so we use the latest commit on the
# pydantic repository, which has the required version of pydantic-core.
# This should ideally be done in `chango`'s dependencies. We can remove this once a new pydantic
# version is released.
"pydantic @ git+https://github.com/pydantic/pydantic ; python_version >= '3.14'"
]
all = ["pre-commit", { include-group = "tests" }, { include-group = "docs" }]

Expand Down
2 changes: 1 addition & 1 deletion tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ such that tests marked with ``@pytest.mark.xdist_group("name")`` are run on the

.. code-block:: bash

$ pytest -n auto --dist=loadgroup
$ pytest -n auto --dist=worksteal

This will result in a significant speedup, but may cause some tests to fail. If you want to run
the failed tests in isolation, you can use the ``--lf`` flag:
Expand Down
5 changes: 4 additions & 1 deletion tests/ext/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
import datetime as dtm
import inspect
import platform
import re

import pytest
Expand Down Expand Up @@ -711,7 +712,9 @@ def test_filters_document_type(self, update):
assert not filters.Document.WAV.check_update(update)
assert not filters.Document.AUDIO.check_update(update)

update.message.document.mime_type = "audio/x-wav"
update.message.document.mime_type = (
"audio/x-wav" if int(platform.python_version_tuple()[1]) < 14 else "audio/vnd.wave"
)
assert filters.Document.WAV.check_update(update)
assert filters.Document.AUDIO.check_update(update)
assert not filters.Document.XML.check_update(update)
Expand Down
Loading