Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for python 3.12 #400

Merged
merged 8 commits into from
Oct 19, 2023
Merged

feat: add support for python 3.12 #400

merged 8 commits into from
Oct 19, 2023

Conversation

parthea
Copy link
Contributor

@parthea parthea commented Oct 19, 2023

Fixes #401
Fixes #402

@parthea
Copy link
Contributor Author

parthea commented Oct 19, 2023

nox > py.test -W=error --quiet --cov=proto --cov-config=.coveragerc --cov-report=term --cov-report=html tests
ImportError while loading conftest '/home/runner/work/proto-plus-python/proto-plus-python/tests/conftest.py'.
tests/conftest.py:[18](https://github.com/googleapis/proto-plus-python/actions/runs/6577031279/job/17867761605?pr=400#step:6:19): in <module>
    from google.protobuf import descriptor_pool
.nox/unitupb-3-12/lib/python3.12/site-packages/google/protobuf/descriptor_pool.py:63: in <module>
    from google.protobuf import descriptor
.nox/unitupb-3-12/lib/python3.12/site-packages/google/protobuf/descriptor.py:40: in <module>
    from google.protobuf.internal import api_implementation
.nox/unitupb-3-12/lib/python3.12/site-packages/google/protobuf/internal/api_implementation.py:74: in <module>
    if _CanImport('google._upb._message'):
.nox/unitupb-3-12/lib/python3.12/site-packages/google/protobuf/internal/api_implementation.py:64: in _CanImport
    mod = importlib.import_module(mod_name)
E   SystemError: <class 'DeprecationWarning'> returned a result with an exception set

See related thread protocolbuffers/protobuf#12186. @ohmayr and I are looking into it.

EDIT: The reason that there is a SystemError is because we're treating warnings as errors when we run tests

"-W=error",

If we remove -W=error all tests pass.

The warnings that appear are as follows:

<frozen importlib._bootstrap>:488
  <frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

<frozen importlib._bootstrap>:488
  <frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

.nox/unit-3-12/lib/python3.12/site-packages/google/protobuf/internal/well_known_types.py:93
  /usr/local/google/home/partheniou/git/proto-plus-python/.nox/unit-3-12/lib/python3.12/site-packages/google/protobuf/internal/well_known_types.py:93: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    _EPOCH_DATETIME_NAIVE = datetime.datetime.utcfromtimestamp(0)

proto/datetime_helpers.py:24
  /usr/local/google/home/partheniou/git/proto-plus-python/proto/datetime_helpers.py:24: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    _UTC_EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc)

Filed #401 for the warning related to proto-plus. The other 3 warnings are in the protobuf code. I'll disable warnings as errors and file a bug to re-enable the -W=error flag once the warnings are fixed upstream.

@parthea parthea marked this pull request as ready for review October 19, 2023 16:58
@parthea parthea requested review from a team as code owners October 19, 2023 16:58
@ohmayr ohmayr self-requested a review October 19, 2023 17:15
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth filing an issue for this, and linking it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #403

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. #403 is the issue tracking this. So fixing #403 MEANS re-enabling the warning.

Suggested change
# The warnings as errors flag `-W=error` was removed in
# TODO(https://github.com/googleapis/proto-plus-python/issues/403): re-enable -W=error
# 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/protocolbuffers/protobuf/issues/12186 is fixed.

@parthea parthea merged commit 1b3a96f into main Oct 19, 2023
26 checks passed
@parthea parthea deleted the python-312 branch October 19, 2023 17:30
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. #403 is the issue tracking this. So fixing #403 MEANS re-enabling the warning.

Suggested change
# The warnings as errors flag `-W=error` was removed in
# TODO(https://github.com/googleapis/proto-plus-python/issues/403): re-enable -W=error
# 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/protocolbuffers/protobuf/issues/12186 is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants