@@ -417,24 +417,18 @@ def write_enum_values(
417417
418418 scl = scl_prefix + [i ]
419419 # Class level
420- if class_attributes :
421- if val .options .deprecated :
422- self ._write_line ("@property" )
423- self ._write_deprecation_warning (
424- scl + [d .EnumValueDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .EnumOptions .DEPRECATED_FIELD_NUMBER ],
425- "This enum value has been marked as deprecated using proto enum value options." ,
426- )
427- self ._write_line (
428- f"def { val .name } (self) -> { value_type } : { '' if self ._has_comments (scl ) else '...' } # { val .number } " ,
429- )
430- with self ._indent ():
431- self ._write_comments (scl )
432- else :
433- self ._write_line (
434- f"{ val .name } : { value_type } # { val .number } " ,
435- )
420+ if class_attributes and val .options .deprecated :
421+ self ._write_line ("@property" )
422+ self ._write_deprecation_warning (
423+ scl + [d .EnumValueDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .EnumOptions .DEPRECATED_FIELD_NUMBER ],
424+ "This enum value has been marked as deprecated using proto enum value options." ,
425+ )
426+ self ._write_line (
427+ f"def { val .name } (self) -> { value_type } : { '' if self ._has_comments (scl ) else '...' } # { val .number } " ,
428+ )
429+ with self ._indent ():
436430 self ._write_comments (scl )
437- # Module level
431+ # Module level or non-deprecated class level
438432 else :
439433 self ._write_line (
440434 f"{ val .name } : { value_type } # { val .number } " ,
@@ -587,8 +581,7 @@ def write_messages(
587581 deprecation_scl_field ,
588582 "This field has been marked as deprecated using proto field options." ,
589583 )
590- body = " ..." if not self ._has_comments (scl_field ) else ""
591- wl (f"def { field .name } (self) -> { field_type } :{ body } " )
584+ wl (f"def { field .name } (self) -> { field_type } :{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
592585 if self ._has_comments (scl_field ):
593586 with self ._indent ():
594587 self ._write_comments (scl_field )
@@ -598,8 +591,7 @@ def write_messages(
598591 deprecation_scl_field ,
599592 "This field has been marked as deprecated using proto field options." ,
600593 )
601- body = " ..." if not self ._has_comments (scl_field ) else ""
602- wl (f"def { field .name } (self, value: { field_type } ) -> None:{ body } " )
594+ wl (f"def { field .name } (self, value: { field_type } ) -> None:{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
603595 if self ._has_comments (scl_field ):
604596 with self ._indent ():
605597 self ._write_comments (scl_field )
@@ -621,8 +613,7 @@ def write_messages(
621613 scl_field + [d .FieldDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .FieldOptions .DEPRECATED_FIELD_NUMBER ],
622614 "This field has been marked as deprecated using proto field options." ,
623615 )
624- body = " ..." if not self ._has_comments (scl_field ) else ""
625- wl (f"def { field .name } (self) -> { field_type } :{ body } " )
616+ wl (f"def { field .name } (self) -> { field_type } :{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
626617 if self ._has_comments (scl_field ):
627618 with self ._indent ():
628619 self ._write_comments (scl_field )
0 commit comments