Skip to content

Commit

Permalink
fix: Remove check for Protobuf version (#474)
Browse files Browse the repository at this point in the history
* fix: Remove check for Protobuf version

* restore unconditional behaviour

* restore behaviour

* restore comment

* catch AttributeError
  • Loading branch information
parthea authored Jul 11, 2024
1 parent e59fc9a commit a1748a3
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions proto/marshal/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
# not be included.

from google.protobuf.internal import containers
import google.protobuf

PROTOBUF_VERSION = google.protobuf.__version__

# Import protobuf 4.xx first and fallback to earlier version
# if not present.
Expand Down Expand Up @@ -51,13 +48,12 @@
repeated_composite_types += (_message.RepeatedCompositeContainer,)
repeated_scalar_types += (_message.RepeatedScalarContainer,)

# In `proto/marshal.py`, for compatibility with protobuf 5.x,
# we'll use `map_composite_type_names` to check whether
# the name of the class of a protobuf type is
# `MessageMapContainer`, and, if `True`, return a MapComposite.
# See https://github.com/protocolbuffers/protobuf/issues/16596
if PROTOBUF_VERSION[0:2] in ["3.", "4."]:
try:
map_composite_types += (_message.MessageMapContainer,)
except AttributeError:
# The `MessageMapContainer` attribute is not available in Protobuf 5.x+
pass


__all__ = (
"repeated_composite_types",
Expand Down

0 comments on commit a1748a3

Please sign in to comment.