Skip to content

Commit

Permalink
Revise the comments based on review.
Browse files Browse the repository at this point in the history
  • Loading branch information
shunping committed Dec 20, 2024
1 parent 1d92b01 commit 7d6dc4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions sdks/python/apache_beam/coders/coders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,12 @@ def __hash__(self):

@classmethod
def from_type_hint(cls, typehint, unused_registry):
# The typehint must be a subclass of google.protobuf.message.Message.
# ProtoCoder cannot work with message.Message itself, as required APIs are
# not implemented in the base class. If this occurs, an error is raised
# and the system defaults to other fallback coders.
# The typehint must be a strict subclass of google.protobuf.message.Message.
# ProtoCoder cannot work with message.Message itself, as deserialization of
# a serialized proto requires knowledge of the desired concrete proto
# subclass which is not stored in the encoded bytes themselves. If this
# occurs, an error is raised and the system defaults to other fallback
# coders.
if (issubclass(typehint, proto_utils.message_types) and
typehint != message.Message):
return cls(typehint)
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/coders/coders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_proto_coder_on_protobuf_message_subclasses(self):

coder = coders_registry.get_coder(message.Message)
# For messages of google.protobuf.message.Message, the fallback coder will
# be FastPrimitiveCoder other than ProtoCoder.
# be FastPrimitivesCoder rather than ProtoCoder.
# See the comment on ProtoCoder.from_type_hint() for further details.
self.assertEqual(coder, coders.FastPrimitivesCoder())

Expand Down

0 comments on commit 7d6dc4a

Please sign in to comment.