Skip to content

Commit dd9dd86

Browse files
anandoleecopybara-github
authored andcommitted
Raise warnings for MessageFactory class usages
PiperOrigin-RevId: 512779287
1 parent 0a480ad commit dd9dd86

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

python/google/protobuf/message_factory.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ def GetPrototype(self, descriptor):
163163
Returns:
164164
A class describing the passed in descriptor.
165165
"""
166-
# TODO(b/258832141): add this warning
167-
# warnings.warn('MessageFactory class is deprecated. Please use '
168-
# 'GetMessageClass() instead of MessageFactory.GetPrototype. '
169-
# 'MessageFactory class will be removed after 2024.')
166+
warnings.warn('MessageFactory class is deprecated. Please use '
167+
'GetMessageClass() instead of MessageFactory.GetPrototype. '
168+
'MessageFactory class will be removed after 2024.')
170169
return GetMessageClass(descriptor)
171170

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

190188
def GetMessages(self, files):
@@ -201,11 +199,10 @@ def GetMessages(self, files):
201199
any dependent messages as well as any messages defined in the same file as
202200
a specified message.
203201
"""
204-
# TODO(b/258832141): add this warning
205-
# warnings.warn('MessageFactory class is deprecated. Please use '
206-
# 'GetMessageClassesForFiles() instead of '
207-
# 'MessageFactory.GetMessages(). MessageFactory class '
208-
# 'will be removed after 2024.')
202+
warnings.warn('MessageFactory class is deprecated. Please use '
203+
'GetMessageClassesForFiles() instead of '
204+
'MessageFactory.GetMessages(). MessageFactory class '
205+
'will be removed after 2024.')
209206
return GetMessageClassesForFiles(files, self.pool)
210207

211208

0 commit comments

Comments
 (0)