Skip to content

Commit 866025a

Browse files
authored
feat: Add support for Python 3.13 (#2215)
1 parent 6712aaf commit 866025a

File tree

25 files changed

+140
-67
lines changed

25 files changed

+140
-67
lines changed

packages/gapic-generator/.github/sync-repo-settings.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ branchProtectionRules:
1212
- 'mypy (3.10)'
1313
- 'mypy (3.11)'
1414
- 'mypy (3.12)'
15+
- 'mypy (3.13)'
1516
- 'showcase (3.7, showcase)'
16-
- 'showcase (3.12, showcase)'
17+
- 'showcase (3.13, showcase)'
1718
- 'showcase (3.7, showcase_alternative_templates)'
18-
- 'showcase (3.12, showcase_alternative_templates)'
19-
- 'showcase (3.7, _w_rest_async)'
20-
- 'showcase (3.12, _w_rest_async)'
19+
- 'showcase (3.13, showcase_alternative_templates)'
20+
- 'showcase (3.7, showcase_w_rest_async)'
21+
- 'showcase (3.13, showcase_w_rest_async)'
2122
# TODO(dovs): reenable these when the mtls tests have been debugged and fixed
2223
# See #1218 for details
2324
# - 'showcase-mtls (showcase_mtls)'
@@ -30,30 +31,35 @@ branchProtectionRules:
3031
- 'showcase-unit (3.10)'
3132
- 'showcase-unit (3.11)'
3233
- 'showcase-unit (3.12)'
34+
- 'showcase-unit (3.13)'
3335
- 'showcase-unit (3.7, _alternative_templates)'
3436
- 'showcase-unit (3.8, _alternative_templates)'
3537
- 'showcase-unit (3.9, _alternative_templates)'
3638
- 'showcase-unit (3.10, _alternative_templates)'
3739
- 'showcase-unit (3.11, _alternative_templates)'
3840
- 'showcase-unit (3.12, _alternative_templates)'
41+
- 'showcase-unit (3.13, _alternative_templates)'
3942
- 'showcase-unit (3.7, _alternative_templates_mixins)'
4043
- 'showcase-unit (3.8, _alternative_templates_mixins)'
4144
- 'showcase-unit (3.9, _alternative_templates_mixins)'
4245
- 'showcase-unit (3.10, _alternative_templates_mixins)'
4346
- 'showcase-unit (3.11, _alternative_templates_mixins)'
4447
- 'showcase-unit (3.12, _alternative_templates_mixins)'
48+
- 'showcase-unit (3.13, _alternative_templates_mixins)'
4549
- 'showcase-unit (3.7, _mixins)'
4650
- 'showcase-unit (3.8, _mixins)'
4751
- 'showcase-unit (3.9, _mixins)'
4852
- 'showcase-unit (3.10, _mixins)'
4953
- 'showcase-unit (3.11, _mixins)'
5054
- 'showcase-unit (3.12, _mixins)'
55+
- 'showcase-unit (3.13, _mixins)'
5156
- 'showcase-unit (3.7, _w_rest_async)'
5257
- 'showcase-unit (3.8, _w_rest_async)'
5358
- 'showcase-unit (3.9, _w_rest_async)'
5459
- 'showcase-unit (3.10, _w_rest_async)'
5560
- 'showcase-unit (3.11, _w_rest_async)'
5661
- 'showcase-unit (3.12, _w_rest_async)'
62+
- 'showcase-unit (3.13, _w_rest_async)'
5763
- 'showcase-unit-add-iam-methods'
5864
- 'integration'
5965
- 'goldens-lint'
@@ -67,18 +73,21 @@ branchProtectionRules:
6773
- 'unit (3.10)'
6874
- 'unit (3.11)'
6975
- 'unit (3.12)'
76+
- 'unit (3.13)'
7077
- 'fragment (3.7)'
7178
- 'fragment (3.8)'
7279
- 'fragment (3.9)'
7380
- 'fragment (3.10)'
7481
- 'fragment (3.11)'
7582
- 'fragment (3.12)'
83+
- 'fragment (3.13)'
7684
- 'fragment (3.7, _alternative_templates)'
7785
- 'fragment (3.8, _alternative_templates)'
7886
- 'fragment (3.9, _alternative_templates)'
7987
- 'fragment (3.10, _alternative_templates)'
8088
- 'fragment (3.11, _alternative_templates)'
8189
- 'fragment (3.12, _alternative_templates)'
90+
- 'fragment (3.13, _alternative_templates)'
8291
- 'OwlBot Post Processor'
8392
requiredApprovingReviewCount: 1
8493
requiresCodeOwnerReviews: true

packages/gapic-generator/.github/workflows/tests.yaml

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
matrix:
3939
# Run mypy on all of the supported python versions listed in setup.py
4040
# https://github.com/python/mypy/blob/master/setup.py
41-
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
41+
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v4
@@ -56,7 +56,7 @@ jobs:
5656
# Run showcase tests on the lowest and highest supported runtimes
5757
matrix:
5858
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA.
59-
python: ["3.7", "3.12"]
59+
python: ["3.7", "3.13"]
6060
target: [showcase, showcase_alternative_templates, showcase_w_rest_async]
6161
runs-on: ubuntu-latest
6262
steps:
@@ -104,10 +104,10 @@ jobs:
104104
run: |
105105
sudo mkdir -p /tmp/workspace/tests/cert/
106106
sudo chown -R ${USER} /tmp/workspace/
107-
- name: Set up Python "3.12"
107+
- name: Set up Python "3.13"
108108
uses: actions/setup-python@v5
109109
with:
110-
python-version: "3.12"
110+
python-version: "3.13"
111111
cache: 'pip'
112112
- name: Copy mtls files
113113
run: cp tests/cert/mtls.* /tmp/workspace/tests/cert/
@@ -140,7 +140,7 @@ jobs:
140140
showcase-unit:
141141
strategy:
142142
matrix:
143-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
143+
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
144144
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA.
145145
variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async]
146146
runs-on: ubuntu-latest
@@ -171,10 +171,10 @@ jobs:
171171
runs-on: ubuntu-latest
172172
steps:
173173
- uses: actions/checkout@v4
174-
- name: Set up Python "3.12"
174+
- name: Set up Python "3.13"
175175
uses: actions/setup-python@v5
176176
with:
177-
python-version: "3.12"
177+
python-version: "3.13"
178178
cache: 'pip'
179179
- name: Install system dependencies.
180180
run: |
@@ -199,10 +199,10 @@ jobs:
199199
variant: ['', _alternative_templates]
200200
steps:
201201
- uses: actions/checkout@v4
202-
- name: Set up Python "3.12"
202+
- name: Set up Python "3.13"
203203
uses: actions/setup-python@v5
204204
with:
205-
python-version: "3.12"
205+
python-version: "3.13"
206206
cache: 'pip'
207207
- name: Install system dependencies.
208208
run: |
@@ -224,10 +224,10 @@ jobs:
224224
runs-on: ubuntu-latest
225225
steps:
226226
- uses: actions/checkout@v4
227-
- name: Set up Python "3.12"
227+
- name: Set up Python "3.13"
228228
uses: actions/setup-python@v5
229229
with:
230-
python-version: "3.12"
230+
python-version: "3.13"
231231
cache: 'pip'
232232
- name: Install system dependencies.
233233
run: |
@@ -240,7 +240,7 @@ jobs:
240240
unit:
241241
strategy:
242242
matrix:
243-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
243+
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
244244
runs-on: ubuntu-latest
245245
steps:
246246
- uses: actions/checkout@v4
@@ -261,7 +261,7 @@ jobs:
261261
fragment:
262262
strategy:
263263
matrix:
264-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
264+
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
265265
variant: ['', _alternative_templates]
266266
runs-on: ubuntu-latest
267267
steps:
@@ -313,29 +313,29 @@ jobs:
313313
runs-on: ubuntu-latest
314314
steps:
315315
- uses: actions/checkout@v4
316-
- name: Set up Python 3.12
316+
- name: Set up Python 3.13
317317
uses: actions/setup-python@v5
318318
with:
319-
python-version: "3.12"
319+
python-version: "3.13"
320320
cache: 'pip'
321321
- name: Install nox.
322322
run: |
323323
python -m pip install nox
324324
- name: Run blacken and lint on the generated output.
325325
run: |
326-
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-3.12 blacken lint
327-
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-3.12 blacken lint
328-
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-3.12 blacken lint
329-
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-3.12 blacken lint
330-
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-3.12 blacken lint
326+
nox -f tests/integration/goldens/asset/noxfile.py -s mypy-3.13 blacken lint
327+
nox -f tests/integration/goldens/credentials/noxfile.py -s mypy-3.13 blacken lint
328+
nox -f tests/integration/goldens/eventarc/noxfile.py -s mypy-3.13 blacken lint
329+
nox -f tests/integration/goldens/logging/noxfile.py -s mypy-3.13 blacken lint
330+
nox -f tests/integration/goldens/redis/noxfile.py -s mypy-3.13 blacken lint
331331
goldens-unit:
332332
runs-on: ubuntu-latest
333333
steps:
334334
- uses: actions/checkout@v4
335-
- name: Set up Python 3.12
335+
- name: Set up Python 3.13
336336
uses: actions/setup-python@v5
337337
with:
338-
python-version: "3.12"
338+
python-version: "3.13"
339339
cache: 'pip'
340340
- name: Install nox.
341341
run: |
@@ -345,18 +345,18 @@ jobs:
345345
# in order to run unit tests
346346
# See https://github.com/googleapis/gapic-generator-python/issues/1806
347347
run: |
348-
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-3.12
349-
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-3.12
350-
nox -f tests/integration/goldens/logging/noxfile.py -s unit-3.12
351-
nox -f tests/integration/goldens/redis/noxfile.py -s unit-3.12
348+
nox -f tests/integration/goldens/credentials/noxfile.py -s unit-3.13
349+
nox -f tests/integration/goldens/eventarc/noxfile.py -s unit-3.13
350+
nox -f tests/integration/goldens/logging/noxfile.py -s unit-3.13
351+
nox -f tests/integration/goldens/redis/noxfile.py -s unit-3.13
352352
goldens-prerelease:
353353
runs-on: ubuntu-latest
354354
steps:
355355
- uses: actions/checkout@v4
356-
- name: Set up Python 3.12
356+
- name: Set up Python 3.13
357357
uses: actions/setup-python@v5
358358
with:
359-
python-version: "3.12"
359+
python-version: "3.13"
360360
cache: 'pip'
361361
- name: Install nox.
362362
run: |
@@ -374,12 +374,10 @@ jobs:
374374
runs-on: ubuntu-latest
375375
steps:
376376
- uses: actions/checkout@v4
377-
- name: Set up Python "3.11"
377+
- name: Set up Python "3.13"
378378
uses: actions/setup-python@v5
379379
with:
380-
# Do not upgrade this check to python 3.12 until
381-
# https://github.com/hhatto/autopep8/issues/712 is fixed
382-
python-version: "3.11"
380+
python-version: "3.13"
383381
cache: 'pip'
384382
- name: Install autopep8
385383
run: |

packages/gapic-generator/gapic/ads-templates/noxfile.py.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ALL_PYTHON = [
1414
"3.10",
1515
"3.11",
1616
"3.12",
17+
"3.13",
1718
]
1819

1920
@nox.session(python=ALL_PYTHON)

packages/gapic-generator/gapic/ads-templates/setup.py.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ setuptools.setup(
7272
"Programming Language :: Python :: 3.10",
7373
"Programming Language :: Python :: 3.11",
7474
"Programming Language :: Python :: 3.12",
75+
"Programming Language :: Python :: 3.13",
7576
"Operating System :: OS Independent",
7677
"Topic :: Internet",
7778
],

packages/gapic-generator/gapic/samplegen/samplegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ def _fill_sample_metadata(sample: dict, api_schema: api.API):
10881088
if not method.void:
10891089
snippet_metadata.client_method.result_type = method.client_output_async.ident.sphinx if async_ else method.client_output.ident.sphinx
10901090
if method.server_streaming:
1091-
snippet_metadata.client_method.result_type = f"Iterable[{snippet_metadata.client_method.result_type }]"
1091+
snippet_metadata.client_method.result_type = f"Iterable[{snippet_metadata.client_method.result_type}]"
10921092

10931093
# Client Method Parameters
10941094
parameters = snippet_metadata.client_method.parameters

packages/gapic-generator/gapic/templates/noxfile.py.j2

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ ALL_PYTHON = [
1818
"3.9",
1919
"3.10",
2020
"3.11",
21-
"3.12"
21+
"3.12",
22+
"3.13",
2223
]
2324

2425
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
@@ -28,7 +29,7 @@ PACKAGE_NAME = '{{ api.naming.warehouse_package_name }}'
2829

2930
BLACK_VERSION = "black==22.3.0"
3031
BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"]
31-
DEFAULT_PYTHON_VERSION = "3.12"
32+
DEFAULT_PYTHON_VERSION = "3.13"
3233

3334
nox.sessions = [
3435
"unit",
@@ -50,7 +51,7 @@ nox.sessions = [
5051
def unit(session, protobuf_implementation):
5152
"""Run the unit test suite."""
5253

53-
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
54+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
5455
session.skip("cpp implementation is not supported in python 3.11+")
5556

5657
session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"')
@@ -84,7 +85,7 @@ def unit(session, protobuf_implementation):
8485
def prerelease_deps(session, protobuf_implementation):
8586
"""Run the unit test suite against pre-release versions of dependencies."""
8687

87-
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
88+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
8889
session.skip("cpp implementation is not supported in python 3.11+")
8990

9091
# Install test environment dependencies
@@ -119,7 +120,8 @@ def prerelease_deps(session, protobuf_implementation):
119120
"googleapis-common-protos",
120121
"google-api-core",
121122
"google-auth",
122-
"grpcio",
123+
# Exclude grpcio!=1.67.0rc1 which does not support python 3.13
124+
"grpcio!=1.67.0rc1",
123125
"grpcio-status",
124126
"protobuf",
125127
"proto-plus",

packages/gapic-generator/gapic/templates/setup.py.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies = [
3737
# See https://github.com/googleapis/google-cloud-python/issues/12364
3838
"google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0",
3939
"proto-plus >= 1.22.3, <2.0.0dev",
40+
"proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'",
4041
{# Explicitly exclude protobuf versions mentioned in https://cloud.google.com/support/bulletins#GCP-2022-019 #}
4142
"protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
4243
{% for package_tuple, package_info in pypi_packages.items() %}
@@ -91,6 +92,7 @@ setuptools.setup(
9192
"Programming Language :: Python :: 3.10",
9293
"Programming Language :: Python :: 3.11",
9394
"Programming Language :: Python :: 3.12",
95+
"Programming Language :: Python :: 3.13",
9496
"Operating System :: OS Independent",
9597
"Topic :: Internet",
9698
],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- coding: utf-8 -*-
2+
{% block constraints %}
3+
{% include "testing/_default_constraints.j2" %}
4+
{% endblock %}

packages/gapic-generator/noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"3.10",
4141
"3.11",
4242
"3.12",
43+
"3.13",
4344
)
4445

4546
NEWEST_PYTHON = ALL_PYTHON[-1]

packages/gapic-generator/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"Programming Language :: Python :: 3.10",
7777
"Programming Language :: Python :: 3.11",
7878
"Programming Language :: Python :: 3.12",
79+
"Programming Language :: Python :: 3.13",
7980
"Operating System :: OS Independent",
8081
"Topic :: Software Development :: Code Generators",
8182
"Topic :: Software Development :: Libraries :: Python Modules",

0 commit comments

Comments
 (0)