From 1b3a96fae7a21bf0120a79ba6bf57aacfd2a0db4 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 13:30:02 -0400 Subject: [PATCH] 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 --- .github/workflows/tests.yml | 4 +++- noxfile.py | 8 +++++++- proto/datetime_helpers.py | 3 ++- setup.py | 1 + testing/constraints-3.12.txt | 0 5 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 testing/constraints-3.12.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9da7dff5..e28374fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,11 +42,13 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] + python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] variant: ['', 'cpp', 'upb'] exclude: - variant: "cpp" python: 3.11 + - variant: "cpp" + python: 3.12 steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} diff --git a/noxfile.py b/noxfile.py index e271fa87..6addf9ed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -29,6 +29,7 @@ "3.9", "3.10", "3.11", + "3.12", ] # Error if a python version is missing @@ -48,9 +49,14 @@ def unit(session, proto="python"): session.install("-e", ".[testing]", "-c", constraints_path) if proto == "cpp": # 4.20 does not have cpp. session.install("protobuf==3.19.0") + + # The warnings as errors flag `-W=error` was removed in + # https://github.com/googleapis/proto-plus-python/pull/400. + # It should be re-added once issue + # https://github.com/googleapis/proto-plus-python/issues/403 is fixed. + # See also https://github.com/protocolbuffers/protobuf/issues/12186. session.run( "py.test", - "-W=error", "--quiet", *( session.posargs # Coverage info when running individual tests is annoying. diff --git a/proto/datetime_helpers.py b/proto/datetime_helpers.py index 7a3aafec..ffac4f47 100644 --- a/proto/datetime_helpers.py +++ b/proto/datetime_helpers.py @@ -21,7 +21,8 @@ from google.protobuf import timestamp_pb2 -_UTC_EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc) +_UTC_EPOCH = datetime.datetime.fromtimestamp(0, datetime.timezone.utc) + _RFC3339_MICROS = "%Y-%m-%dT%H:%M:%S.%fZ" _RFC3339_NO_FRACTION = "%Y-%m-%dT%H:%M:%S" # datetime.strptime cannot handle nanosecond precision: parse w/ regex diff --git a/setup.py b/setup.py index 670bca40..759494f4 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,7 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries :: Python Modules", ], diff --git a/testing/constraints-3.12.txt b/testing/constraints-3.12.txt new file mode 100644 index 00000000..e69de29b