From 78596e01935aa6793e51540a4b9c7d68656aea1e Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 11:38:58 -0400 Subject: [PATCH 1/8] feat: add support for python 3.12 --- .github/workflows/tests.yml | 4 ++-- setup.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9da7dff5..e76dbf02 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,11 +42,11 @@ 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 + python: 3.12 steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} 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", ], From cfbe2b2b296e1d20ae2cdf08db467fb1f60cf5d9 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 11:40:45 -0400 Subject: [PATCH 2/8] update exclude --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e76dbf02..e28374fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,6 +45,8 @@ jobs: 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: From 84014738be8171b35680f09ce40a953fe93028d8 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 11:42:12 -0400 Subject: [PATCH 3/8] update noxfile --- noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/noxfile.py b/noxfile.py index e271fa87..08a1f3e9 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 From f15707b8ac199c3810c4f909f79d20fb723d95b9 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 11:43:41 -0400 Subject: [PATCH 4/8] add contraints file --- testing/constraints-3.12.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testing/constraints-3.12.txt diff --git a/testing/constraints-3.12.txt b/testing/constraints-3.12.txt new file mode 100644 index 00000000..e69de29b From a45307ea8909942244c31792156c15802218e94b Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 12:55:52 -0400 Subject: [PATCH 5/8] Disable warnings as errors --- noxfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 08a1f3e9..4ad55224 100644 --- a/noxfile.py +++ b/noxfile.py @@ -51,7 +51,6 @@ def unit(session, proto="python"): session.install("protobuf==3.19.0") session.run( "py.test", - "-W=error", "--quiet", *( session.posargs # Coverage info when running individual tests is annoying. From 9f1161cc781c04bda33a84177bb7dd0070f85be8 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 17:08:45 +0000 Subject: [PATCH 6/8] use datetime.datetime.fromtimestamp instead of datetime.datetime.utcfromtimestamp(0) which is deprecated --- proto/datetime_helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proto/datetime_helpers.py b/proto/datetime_helpers.py index 7a3aafec..c1192f78 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.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 From 72c40a86153521f35fb081c03f631d8efe658dcf Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 17:11:08 +0000 Subject: [PATCH 7/8] use datetime.timezone.utc --- proto/datetime_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/datetime_helpers.py b/proto/datetime_helpers.py index c1192f78..ffac4f47 100644 --- a/proto/datetime_helpers.py +++ b/proto/datetime_helpers.py @@ -21,7 +21,7 @@ from google.protobuf import timestamp_pb2 -_UTC_EPOCH = datetime.datetime.fromtimestamp(0, datetime.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" From 4e673b89a1bc240beee620de09f51f30344e99ec Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 19 Oct 2023 17:25:35 +0000 Subject: [PATCH 8/8] add comment --- noxfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/noxfile.py b/noxfile.py index 4ad55224..6addf9ed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -49,6 +49,12 @@ 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", "--quiet",