Skip to content

Commit febd106

Browse files
committed
refactor(pubsub): remove EOL Python 3.7/3.8/3.9 compatibility checks and skipif tests
1 parent b254faf commit febd106

13 files changed

Lines changed: 13 additions & 160 deletions

File tree

packages/google-cloud-pubsub/CONTRIBUTING.rst

Lines changed: 1 addition & 15 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.9, 3.10, 3.11, 3.12, 3.13 and 3.14 on both UNIX and Windows.
25+
3.10, 3.11, 3.12, 3.13 and 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
@@ -221,14 +221,12 @@ Supported Python Versions
221221

222222
We support:
223223

224-
- `Python 3.9`_
225224
- `Python 3.10`_
226225
- `Python 3.11`_
227226
- `Python 3.12`_
228227
- `Python 3.13`_
229228
- `Python 3.14`_
230229

231-
.. _Python 3.9: https://docs.python.org/3.9/
232230
.. _Python 3.10: https://docs.python.org/3.10/
233231
.. _Python 3.11: https://docs.python.org/3.11/
234232
.. _Python 3.12: https://docs.python.org/3.12/
@@ -241,18 +239,6 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
241239
.. _config: https://github.com/googleapis/python-pubsub/blob/main/noxfile.py
242240

243241

244-
We also explicitly decided to support Python 3 beginning with version 3.7.
245-
Reasons for this include:
246-
247-
- Encouraging use of newest versions of Python 3
248-
- Taking the lead of `prominent`_ open-source `projects`_
249-
- `Unicode literal support`_ which allows for a cleaner codebase that
250-
works in both Python 2 and Python 3
251-
252-
.. _prominent: https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django
253-
.. _projects: http://flask.pocoo.org/docs/0.10/python3/
254-
.. _Unicode literal support: https://www.python.org/dev/peps/pep-0414/
255-
256242
**********
257243
Versioning
258244
**********

packages/google-cloud-pubsub/README.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ Python >= 3.10, including 3.14
6767
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
6868
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
6969

70-
Unsupported Python Versions
71-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
72-
Python <= 3.9
73-
7470

7571
If you are using an `end-of-life`_
7672
version of Python, we recommend that you update as soon as possible to an actively supported version.

packages/google-cloud-pubsub/google/cloud/pubsub_v1/publisher/client.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import copy
1818
import logging
1919
import os
20-
import sys
2120
import threading
2221
import time
2322
import typing
@@ -165,18 +164,6 @@ def __init__(
165164
self._open_telemetry_enabled = (
166165
self.publisher_options.enable_open_telemetry_tracing
167166
)
168-
# OpenTelemetry features used by the library are not supported in Python versions <= 3.7.
169-
# Refer https://github.com/open-telemetry/opentelemetry-python/issues/3993#issuecomment-2211976389
170-
if (
171-
self.publisher_options.enable_open_telemetry_tracing
172-
and sys.version_info.major == 3
173-
and sys.version_info.minor < 8
174-
):
175-
warnings.warn(
176-
message="Open Telemetry for Python version 3.7 or lower is not supported. Disabling Open Telemetry tracing.",
177-
category=RuntimeWarning,
178-
)
179-
self._open_telemetry_enabled = False
180167

181168
@classmethod
182169
def from_service_account_file( # type: ignore[override]

packages/google-cloud-pubsub/google/cloud/pubsub_v1/subscriber/_protocol/leaser.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
)
2828
from google.cloud.pubsub_v1.subscriber._protocol.dispatcher import _MAX_BATCH_LATENCY
2929

30-
try:
31-
from collections.abc import KeysView
32-
33-
KeysView[None] # KeysView is only subscriptable in Python 3.9+
34-
except TypeError:
35-
# Deprecated since Python 3.9, thus only use as a fallback in older Python versions
36-
from typing import KeysView
30+
from collections.abc import KeysView
3731

3832
from google.cloud.pubsub_v1.subscriber._protocol import requests
3933

packages/google-cloud-pubsub/google/cloud/pubsub_v1/subscriber/client.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from __future__ import absolute_import
1616

1717
import os
18-
import sys
1918
import typing
2019
import warnings
2120
from typing import Any, Callable, Optional, Sequence, Union, cast
@@ -102,18 +101,6 @@ def __init__(
102101
self._open_telemetry_enabled = (
103102
self.subscriber_options.enable_open_telemetry_tracing
104103
)
105-
# OpenTelemetry features used by the library are not supported in Python versions <= 3.7.
106-
# Refer https://github.com/open-telemetry/opentelemetry-python/issues/3993#issuecomment-2211976389
107-
if (
108-
self.subscriber_options.enable_open_telemetry_tracing
109-
and sys.version_info.major == 3
110-
and sys.version_info.minor < 8
111-
):
112-
warnings.warn(
113-
message="Open Telemetry for Python version 3.7 or lower is not supported. Disabling Open Telemetry tracing.",
114-
category=RuntimeWarning,
115-
)
116-
self._open_telemetry_enabled = False
117104

118105
@property
119106
def open_telemetry_enabled(self) -> bool:

packages/google-cloud-pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ def shutdown(
153153
"""
154154
dropped_messages = []
155155

156-
# Drop all pending item from the executor. Without this, the executor will also
157-
# try to process any pending work items before termination, which is undesirable.
158-
#
159-
# TODO: Replace the logic below by passing `cancel_futures=True` to shutdown()
160-
# once we only need to support Python 3.9+.
161156
try:
162157
while True:
163158
work_item = self._executor._work_queue.get(block=False)
@@ -185,5 +180,5 @@ def shutdown(
185180
except queue.Empty:
186181
pass
187182

188-
self._executor.shutdown(wait=await_msg_callbacks)
183+
self._executor.shutdown(wait=await_msg_callbacks, cancel_futures=True)
189184
return dropped_messages

packages/google-cloud-pubsub/pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ filterwarnings =
1616
# Remove once the minimum supported version of googleapis-common-protos is 1.62.0
1717
ignore:.*pkg_resources.declare_namespace:DeprecationWarning
1818
ignore:.*pkg_resources is deprecated as an API:DeprecationWarning
19-
# Remove once https://github.com/googleapis/gapic-generator-python/issues/2303 is fixed
20-
ignore:The python-bigquery library will stop supporting Python 3.7:PendingDeprecationWarning
2119
# Remove once we move off credential files https://github.com/googleapis/google-auth-library-python/pull/1812
2220
# Note that these are used in tests only
2321
ignore:Your config file at [/home/kbuilder/.docker/config.json] contains these credential helper entries:DeprecationWarning

packages/google-cloud-pubsub/tests/unit/pubsub_v1/publisher/batch/test_thread.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import datetime
16-
import sys
1716
import threading
1817
import time
1918
from unittest import mock
@@ -723,9 +722,6 @@ def test_batch_done_callback_called_on_publish_response_invalid():
723722

724723

725724
# Refer https://opentelemetry.io/docs/languages/python/#version-support
726-
@pytest.mark.skipif(
727-
sys.version_info < (3, 8), reason="Open Telemetry requires python3.8 or higher"
728-
)
729725
def test_open_telemetry_commit_publish_rpc_span_none(span_exporter):
730726
"""
731727
Test scenario where OpenTelemetry is enabled, publish RPC
@@ -771,9 +767,6 @@ def test_open_telemetry_commit_publish_rpc_span_none(span_exporter):
771767

772768

773769
# Refer https://opentelemetry.io/docs/languages/python/#version-support
774-
@pytest.mark.skipif(
775-
sys.version_info < (3, 8), reason="Open Telemetry requires python3.8 or higher"
776-
)
777770
def test_open_telemetry_commit_publish_rpc_exception(span_exporter):
778771
TOPIC = "projects/projectID/topics/topicID"
779772
batch = create_batch(topic=TOPIC, enable_open_telemetry=True)
@@ -819,9 +812,6 @@ def test_open_telemetry_commit_publish_rpc_exception(span_exporter):
819812

820813

821814
# Refer https://opentelemetry.io/docs/languages/python/#version-support
822-
@pytest.mark.skipif(
823-
sys.version_info < (3, 8), reason="Open Telemetry requires python3.8 or higher"
824-
)
825815
def test_opentelemetry_commit_sampling(span_exporter):
826816
TOPIC = "projects/projectID/topics/topic"
827817
batch = create_batch(
@@ -886,9 +876,6 @@ def test_opentelemetry_commit_sampling(span_exporter):
886876
assert span.events[1].name == "publish end"
887877

888878

889-
@pytest.mark.skipif(
890-
sys.version_info < (3, 8), reason="Open Telemetry requires python3.8 or higher"
891-
)
892879
def test_opentelemetry_commit(span_exporter):
893880
TOPIC = "projects/projectID/topics/topic"
894881
batch = create_batch(

packages/google-cloud-pubsub/tests/unit/pubsub_v1/publisher/test_publisher_client.py

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import inspect
1818
import math
19-
import sys
2019
import time
2120
from typing import Any, Callable, TypeVar, cast
2221
from unittest import mock
@@ -154,28 +153,13 @@ def test_init_w_custom_transport(creds):
154153
)
155154
@typed_flaky
156155
def test_open_telemetry_publisher_options(creds, enable_open_telemetry):
157-
if sys.version_info >= (3, 8) or enable_open_telemetry is False:
158-
client = publisher.Client(
159-
publisher_options=types.PublisherOptions(
160-
enable_open_telemetry_tracing=enable_open_telemetry
161-
),
162-
credentials=creds,
163-
)
164-
assert client._open_telemetry_enabled == enable_open_telemetry
165-
else:
166-
# Open Telemetry is not supported and hence disabled for Python
167-
# versions 3.7 or below
168-
with pytest.warns(
169-
RuntimeWarning,
170-
match="Open Telemetry for Python version 3.7 or lower is not supported. Disabling Open Telemetry tracing.",
171-
):
172-
client = publisher.Client(
173-
publisher_options=types.PublisherOptions(
174-
enable_open_telemetry_tracing=enable_open_telemetry
175-
),
176-
credentials=creds,
177-
)
178-
assert client._open_telemetry_enabled is False
156+
client = publisher.Client(
157+
publisher_options=types.PublisherOptions(
158+
enable_open_telemetry_tracing=enable_open_telemetry
159+
),
160+
credentials=creds,
161+
)
162+
assert client._open_telemetry_enabled == enable_open_telemetry
179163

180164

181165
def test_opentelemetry_context_setter():
@@ -185,10 +169,6 @@ def test_opentelemetry_context_setter():
185169
assert "googclient_key" in msg.attributes.keys()
186170

187171

188-
@pytest.mark.skipif(
189-
sys.version_info < (3, 8),
190-
reason="Open Telemetry not supported below Python version 3.8",
191-
)
192172
def test_opentelemetry_context_propagation(creds, span_exporter):
193173
TOPIC = "projects/projectID/topics/topicID"
194174
client = publisher.Client(
@@ -208,10 +188,6 @@ def test_opentelemetry_context_propagation(creds, span_exporter):
208188
assert "googclient_traceparent" in args[0].attributes
209189

210190

211-
@pytest.mark.skipif(
212-
sys.version_info < (3, 8),
213-
reason="Open Telemetry not supported below Python version 3.8",
214-
)
215191
@pytest.mark.parametrize(
216192
"enable_open_telemetry",
217193
[
@@ -271,10 +247,6 @@ def test_opentelemetry_publisher_batching_exception(
271247
assert len(spans) == 0
272248

273249

274-
@pytest.mark.skipif(
275-
sys.version_info < (3, 8),
276-
reason="Open Telemetry not supported below Python version 3.8",
277-
)
278250
def test_opentelemetry_flow_control_exception(creds, span_exporter):
279251
publisher_options = types.PublisherOptions(
280252
flow_control=types.PublishFlowControl(
@@ -332,10 +304,6 @@ def test_opentelemetry_flow_control_exception(creds, span_exporter):
332304
assert has_exception_event, "Exception event not found in failed create span"
333305

334306

335-
@pytest.mark.skipif(
336-
sys.version_info < (3, 8),
337-
reason="Open Telemetry not supported below Python version 3.8",
338-
)
339307
def test_opentelemetry_publish(creds, span_exporter):
340308
TOPIC = "projects/projectID/topics/topicID"
341309
client = publisher.Client(

packages/google-cloud-pubsub/tests/unit/pubsub_v1/subscriber/test_dispatcher.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import collections
1616
import queue
17-
import sys
1817
import threading
1918
from unittest import mock
2019

@@ -403,10 +402,6 @@ def test_opentelemetry_modify_ack_deadline(span_exporter):
403402
assert subscribe_span.events[1].name == "modack end"
404403

405404

406-
@pytest.mark.skipif(
407-
sys.version_info < (3, 8),
408-
reason="Open Telemetry not supported below Python version 3.8",
409-
)
410405
def test_opentelemetry_ack(span_exporter):
411406
manager = mock.create_autospec(
412407
streaming_pull_manager.StreamingPullManager, instance=True
@@ -602,10 +597,6 @@ def test_retry_acks_in_new_thread():
602597
assert ctor_call.kwargs["daemon"]
603598

604599

605-
@pytest.mark.skipif(
606-
sys.version_info < (3, 8),
607-
reason="Open Telemetry not supported below Python version 3.8",
608-
)
609600
def test_opentelemetry_retry_acks(span_exporter):
610601
manager = mock.create_autospec(
611602
streaming_pull_manager.StreamingPullManager, instance=True
@@ -789,10 +780,6 @@ def test_opentelemetry_retry_modacks(span_exporter):
789780
assert subscribe_span.events[0].name == "modack end"
790781

791782

792-
@pytest.mark.skipif(
793-
sys.version_info < (3, 8),
794-
reason="Open Telemetry not supported below Python version 3.8",
795-
)
796783
def test_opentelemetry_retry_nacks(span_exporter):
797784
manager = mock.create_autospec(
798785
streaming_pull_manager.StreamingPullManager, instance=True
@@ -959,10 +946,6 @@ def test_drop_ordered_messages():
959946
manager.maybe_resume_consumer.assert_called_once()
960947

961948

962-
@pytest.mark.skipif(
963-
sys.version_info < (3, 8),
964-
reason="Open Telemetry not supported below Python version 3.8",
965-
)
966949
def test_opentelemetry_nack(span_exporter):
967950
manager = mock.create_autospec(
968951
streaming_pull_manager.StreamingPullManager, instance=True

0 commit comments

Comments
 (0)