Skip to content

Commit

Permalink
Raise warnings for MessageFactory class usages
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 512779287
  • Loading branch information
anandolee authored and copybara-github committed Feb 28, 2023
1 parent 0a480ad commit dd9dd86
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions python/google/protobuf/message_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ def GetPrototype(self, descriptor):
Returns:
A class describing the passed in descriptor.
"""
# TODO(b/258832141): add this warning
# warnings.warn('MessageFactory class is deprecated. Please use '
# 'GetMessageClass() instead of MessageFactory.GetPrototype. '
# 'MessageFactory class will be removed after 2024.')
warnings.warn('MessageFactory class is deprecated. Please use '
'GetMessageClass() instead of MessageFactory.GetPrototype. '
'MessageFactory class will be removed after 2024.')
return GetMessageClass(descriptor)

def CreatePrototype(self, descriptor):
Expand All @@ -181,10 +180,9 @@ def CreatePrototype(self, descriptor):
Returns:
A class describing the passed in descriptor.
"""
# TODO(b/258832141): add this warning
# warnings.warn('Directly call CreatePrototype is wrong. Please use '
# 'GetMessageClass() method instead. Directly use '
# 'CreatePrototype will raise error after July 2023.')
warnings.warn('Directly call CreatePrototype is wrong. Please use '
'GetMessageClass() method instead. Directly use '
'CreatePrototype will raise error after July 2023.')
return _InternalCreateMessageClass(descriptor)

def GetMessages(self, files):
Expand All @@ -201,11 +199,10 @@ def GetMessages(self, files):
any dependent messages as well as any messages defined in the same file as
a specified message.
"""
# TODO(b/258832141): add this warning
# warnings.warn('MessageFactory class is deprecated. Please use '
# 'GetMessageClassesForFiles() instead of '
# 'MessageFactory.GetMessages(). MessageFactory class '
# 'will be removed after 2024.')
warnings.warn('MessageFactory class is deprecated. Please use '
'GetMessageClassesForFiles() instead of '
'MessageFactory.GetMessages(). MessageFactory class '
'will be removed after 2024.')
return GetMessageClassesForFiles(files, self.pool)


Expand Down

0 comments on commit dd9dd86

Please sign in to comment.