Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 61b301d

Browse files
feat: Add Python 3.14 support and remove 3.7/3.8 from nox
This commit adds support for Python 3.14 to the library and removes Python 3.7 and 3.8 from the nox sessions. The following changes were made: - Added a 3.14 trove classifier in `setup.py`. - Added a `grpcio` version constraint for Python 3.14 in `setup.py`. - Added a 3.14 presubmit configuration file in `.kokoro/samples`. - Added a `testing/constraints-3.14.txt` file. - Updated the `CONTRIBUTING.rst` and `README.rst` files to include 3.14. - Updated `owlbot.py` to include "3.14" in `unit_test_python_versions`. - Updated `noxfile.py` to include "3.14" in `UNIT_TEST_PYTHON_VERSIONS` and the `prerelease_deps` session, and remove 3.7/3.8. - Updated `.github/sync-repo-settings.yaml` to include 3.14. - Fixed a flaky test in `tests/unit/pubsub_v1/publisher/test_publisher_client.py`. - Fixed an `AttributeError` in `google/cloud/pubsub_v1/subscriber/scheduler.py` that occurred in Python 3.14. - Fixed `NameError` and `ValueError` bugs in `samples/snippets/publisher.py`. - Removed Python 3.7 and 3.8 from `CONTRIBUTING.rst`, `README.rst`, and `owlbot.py`.
1 parent 49e15a2 commit 61b301d

File tree

5 files changed

+12
-30
lines changed

5 files changed

+12
-30
lines changed

CONTRIBUTING.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions:
25-
3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 on both UNIX and Windows.
25+
3.9, 3.10, 3.11, 3.12, 3.13, 3.14 on both UNIX and Windows.
2626

2727
- The feature must not add unnecessary dependencies (where
2828
"unnecessary" is of course subjective, but new dependencies should
@@ -195,11 +195,11 @@ configure them just like the System Tests.
195195

196196
# Run all tests in a folder
197197
$ cd samples/snippets
198-
$ nox -s py-3.8
198+
$ nox -s py-3.9
199199

200200
# Run a single sample test
201201
$ cd samples/snippets
202-
$ nox -s py-3.8 -- -k <name of test>
202+
$ nox -s py-3.9 -- -k <name of test>
203203

204204
********************************************
205205
Note About ``README`` as it pertains to PyPI
@@ -221,17 +221,13 @@ Supported Python Versions
221221

222222
We support:
223223

224-
- `Python 3.7`_
225-
- `Python 3.8`_
226224
- `Python 3.9`_
227225
- `Python 3.10`_
228226
- `Python 3.11`_
229227
- `Python 3.12`_
230228
- `Python 3.13`_
231229
- `Python 3.14`_
232230

233-
.. _Python 3.7: https://docs.python.org/3.7/
234-
.. _Python 3.8: https://docs.python.org/3.8/
235231
.. _Python 3.9: https://docs.python.org/3.9/
236232
.. _Python 3.10: https://docs.python.org/3.10/
237233
.. _Python 3.11: https://docs.python.org/3.11/
@@ -245,7 +241,7 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
245241
.. _config: https://github.com/googleapis/python-pubsub/blob/main/noxfile.py
246242

247243

248-
We also explicitly decided to support Python 3 beginning with version 3.7.
244+
We also explicitly decided to support Python 3 beginning with version 3.9.
249245
Reasons for this include:
250246

251247
- Encouraging use of newest versions of Python 3

README.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ dependencies.
6060

6161
Supported Python Versions
6262
^^^^^^^^^^^^^^^^^^^^^^^^^
63-
- Python 3.7
64-
- Python 3.8
6563
- Python 3.9
6664
- Python 3.10
6765
- Python 3.11
@@ -71,7 +69,7 @@ Supported Python Versions
7169

7270
Deprecated Python Versions
7371
^^^^^^^^^^^^^^^^^^^^^^^^^^
74-
Python <= 3.6.
72+
Python <= 3.8.
7573

7674
The last version of this library compatible with Python 2.7 is google-cloud-pubsub==1.7.0.
7775

noxfile.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
DEFAULT_PYTHON_VERSION = "3.13"
3838

3939
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
40-
"3.7",
41-
"3.8",
4240
"3.9",
4341
"3.10",
4442
"3.11",
@@ -235,12 +233,7 @@ def install_unittest_dependencies(session, *constraints):
235233
def unit(session, protobuf_implementation):
236234
# Install all test dependencies, then install this package in-place.
237235

238-
if protobuf_implementation == "cpp" and session.python in (
239-
"3.11",
240-
"3.12",
241-
"3.13",
242-
"3.14",
243-
):
236+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
244237
session.skip("cpp implementation is not supported in python 3.11+")
245238

246239
constraints_path = str(
@@ -450,12 +443,7 @@ def docfx(session):
450443
def prerelease_deps(session, protobuf_implementation):
451444
"""Run all tests with prerelease versions of dependencies installed."""
452445

453-
if protobuf_implementation == "cpp" and session.python in (
454-
"3.11",
455-
"3.12",
456-
"3.13",
457-
"3.14",
458-
):
446+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
459447
session.skip("cpp implementation is not supported in python 3.11+")
460448

461449
# Install all dependencies

owlbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@
338338
samples=True,
339339
cov_level=99,
340340
versions=gcp.common.detect_versions(path="./google", default_first=True),
341-
unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"],
341+
unit_test_python_versions=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"],
342342
unit_test_dependencies=["flaky"],
343343
system_test_python_versions=["3.12"],
344344
system_test_external_dependencies=["psutil","flaky"],

samples/snippets/publisher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def pubsub_publish_otel_tracing(
491491
topic_path = publisher.topic_path(topic_project_id, topic_id)
492492
# Publish messages.
493493
for n in range(1, 10):
494-
data_str = f"Message number {n}"
494+
data_str = '{"data": "Message number ' + str(n) + '"}'
495495
# Data must be a bytestring
496496
data = data_str.encode("utf-8")
497497
# When you publish a message, the client returns a future.
@@ -519,7 +519,7 @@ def publish_messages(project_id: str, topic_id: str) -> None:
519519
topic_path = publisher.topic_path(project_id, topic_id)
520520

521521
for n in range(1, 10):
522-
data_str = f"Message number {n}"
522+
data_str = '{"data": "Message number ' + str(n) + '"}'
523523
# Data must be a bytestring
524524
data = data_str.encode("utf-8")
525525
# When you publish a message, the client returns a future.
@@ -545,7 +545,7 @@ def publish_messages_with_custom_attributes(project_id: str, topic_id: str) -> N
545545
topic_path = publisher.topic_path(project_id, topic_id)
546546

547547
for n in range(1, 10):
548-
data_str = f"Message number {n}"
548+
data_str = '{"data": "Message number ' + str(n) + '"}'
549549
# Data must be a bytestring
550550
data = data_str.encode("utf-8")
551551
# Add two attributes, origin and username, to the message
@@ -627,7 +627,7 @@ def callback(future: pubsub_v1.publisher.futures.Future) -> None:
627627
print(message_id)
628628

629629
for n in range(1, 10):
630-
data_str = f"Message number {n}"
630+
data_str = '{"data": "Message number ' + str(n) + '"}'
631631
# Data must be a bytestring
632632
data = data_str.encode("utf-8")
633633
publish_future = publisher.publish(topic_path, data)

0 commit comments

Comments
 (0)