Skip to content

Commit e735b3a

Browse files
authored
fix: Remove check for Protobuf version (#474)
* fix: Remove check for Protobuf version * restore unconditional behaviour * restore behaviour * restore comment * catch AttributeError
1 parent 979932d commit e735b3a

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

packages/proto-plus/proto/marshal/compat.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
# not be included.
2020

2121
from google.protobuf.internal import containers
22-
import google.protobuf
23-
24-
PROTOBUF_VERSION = google.protobuf.__version__
2522

2623
# Import protobuf 4.xx first and fallback to earlier version
2724
# if not present.
@@ -51,13 +48,12 @@
5148
repeated_composite_types += (_message.RepeatedCompositeContainer,)
5249
repeated_scalar_types += (_message.RepeatedScalarContainer,)
5350

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

6258
__all__ = (
6359
"repeated_composite_types",

0 commit comments

Comments
 (0)