@@ -369,24 +369,18 @@ def write_enum_values(
369369
370370 scl = scl_prefix + [i ]
371371 # Class level
372- if class_attributes :
373- if val .options .deprecated :
374- self ._write_line ("@property" )
375- self ._write_deprecation_warning (
376- scl + [d .EnumValueDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .EnumOptions .DEPRECATED_FIELD_NUMBER ],
377- "This enum value has been marked as deprecated using proto enum value options." ,
378- )
379- self ._write_line (
380- f"def { val .name } (self) -> { value_type } : { '' if self ._has_comments (scl ) else '...' } # { val .number } " ,
381- )
382- with self ._indent ():
383- self ._write_comments (scl )
384- else :
385- self ._write_line (
386- f"{ val .name } : { value_type } # { val .number } " ,
387- )
372+ if class_attributes and val .options .deprecated :
373+ self ._write_line ("@property" )
374+ self ._write_deprecation_warning (
375+ scl + [d .EnumValueDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .EnumOptions .DEPRECATED_FIELD_NUMBER ],
376+ "This enum value has been marked as deprecated using proto enum value options." ,
377+ )
378+ self ._write_line (
379+ f"def { val .name } (self) -> { value_type } : { '' if self ._has_comments (scl ) else '...' } # { val .number } " ,
380+ )
381+ with self ._indent ():
388382 self ._write_comments (scl )
389- # Module level
383+ # Module level or non-deprecated class level
390384 else :
391385 self ._write_line (
392386 f"{ val .name } : { value_type } # { val .number } " ,
@@ -539,8 +533,7 @@ def write_messages(
539533 deprecation_scl_field ,
540534 "This field has been marked as deprecated using proto field options." ,
541535 )
542- body = " ..." if not self ._has_comments (scl_field ) else ""
543- wl (f"def { field .name } (self) -> { field_type } :{ body } " )
536+ wl (f"def { field .name } (self) -> { field_type } :{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
544537 if self ._has_comments (scl_field ):
545538 with self ._indent ():
546539 self ._write_comments (scl_field )
@@ -550,8 +543,7 @@ def write_messages(
550543 deprecation_scl_field ,
551544 "This field has been marked as deprecated using proto field options." ,
552545 )
553- body = " ..." if not self ._has_comments (scl_field ) else ""
554- wl (f"def { field .name } (self, value: { field_type } ) -> None:{ body } " )
546+ wl (f"def { field .name } (self, value: { field_type } ) -> None:{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
555547 if self ._has_comments (scl_field ):
556548 with self ._indent ():
557549 self ._write_comments (scl_field )
@@ -573,8 +565,7 @@ def write_messages(
573565 scl_field + [d .FieldDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .FieldOptions .DEPRECATED_FIELD_NUMBER ],
574566 "This field has been marked as deprecated using proto field options." ,
575567 )
576- body = " ..." if not self ._has_comments (scl_field ) else ""
577- wl (f"def { field .name } (self) -> { field_type } :{ body } " )
568+ wl (f"def { field .name } (self) -> { field_type } :{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
578569 if self ._has_comments (scl_field ):
579570 with self ._indent ():
580571 self ._write_comments (scl_field )
0 commit comments