Skip to content

Commit cbe5cb4

Browse files
authored
feat: add support for python 3.12 (#400)
* feat: add support for python 3.12 * update exclude * update noxfile * add contraints file * Disable warnings as errors * use datetime.datetime.fromtimestamp instead of datetime.datetime.utcfromtimestamp(0) which is deprecated * use datetime.timezone.utc * add comment
1 parent f329fbd commit cbe5cb4

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

packages/proto-plus/.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ jobs:
4242
runs-on: ubuntu-20.04
4343
strategy:
4444
matrix:
45-
python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
45+
python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
4646
variant: ['', 'cpp', 'upb']
4747
exclude:
4848
- variant: "cpp"
4949
python: 3.11
50+
- variant: "cpp"
51+
python: 3.12
5052
steps:
5153
- uses: actions/checkout@v4
5254
- name: Set up Python ${{ matrix.python }}

packages/proto-plus/noxfile.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"3.9",
3030
"3.10",
3131
"3.11",
32+
"3.12",
3233
]
3334

3435
# Error if a python version is missing
@@ -48,9 +49,14 @@ def unit(session, proto="python"):
4849
session.install("-e", ".[testing]", "-c", constraints_path)
4950
if proto == "cpp": # 4.20 does not have cpp.
5051
session.install("protobuf==3.19.0")
52+
53+
# The warnings as errors flag `-W=error` was removed in
54+
# https://github.com/googleapis/proto-plus-python/pull/400.
55+
# It should be re-added once issue
56+
# https://github.com/googleapis/proto-plus-python/issues/403 is fixed.
57+
# See also https://github.com/protocolbuffers/protobuf/issues/12186.
5158
session.run(
5259
"py.test",
53-
"-W=error",
5460
"--quiet",
5561
*(
5662
session.posargs # Coverage info when running individual tests is annoying.

packages/proto-plus/proto/datetime_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from google.protobuf import timestamp_pb2
2222

2323

24-
_UTC_EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc)
24+
_UTC_EPOCH = datetime.datetime.fromtimestamp(0, datetime.timezone.utc)
25+
2526
_RFC3339_MICROS = "%Y-%m-%dT%H:%M:%S.%fZ"
2627
_RFC3339_NO_FRACTION = "%Y-%m-%dT%H:%M:%S"
2728
# datetime.strptime cannot handle nanosecond precision: parse w/ regex

packages/proto-plus/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"Programming Language :: Python :: 3.9",
5757
"Programming Language :: Python :: 3.10",
5858
"Programming Language :: Python :: 3.11",
59+
"Programming Language :: Python :: 3.12",
5960
"Topic :: Software Development :: Code Generators",
6061
"Topic :: Software Development :: Libraries :: Python Modules",
6162
],

packages/proto-plus/testing/constraints-3.12.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)