@@ -400,24 +400,18 @@ def write_enum_values(
400400
401401 scl = scl_prefix + [i ]
402402 # Class level
403- if class_attributes :
404- if val .options .deprecated :
405- self ._write_line ("@property" )
406- self ._write_deprecation_warning (
407- scl + [d .EnumValueDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .EnumOptions .DEPRECATED_FIELD_NUMBER ],
408- "This enum value has been marked as deprecated using proto enum value options." ,
409- )
410- self ._write_line (
411- f"def { val .name } (self) -> { value_type } : { '' if self ._has_comments (scl ) else '...' } # { val .number } " ,
412- )
413- with self ._indent ():
414- self ._write_comments (scl )
415- else :
416- self ._write_line (
417- f"{ val .name } : { value_type } # { val .number } " ,
418- )
403+ if class_attributes and val .options .deprecated :
404+ self ._write_line ("@property" )
405+ self ._write_deprecation_warning (
406+ scl + [d .EnumValueDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .EnumOptions .DEPRECATED_FIELD_NUMBER ],
407+ "This enum value has been marked as deprecated using proto enum value options." ,
408+ )
409+ self ._write_line (
410+ f"def { val .name } (self) -> { value_type } : { '' if self ._has_comments (scl ) else '...' } # { val .number } " ,
411+ )
412+ with self ._indent ():
419413 self ._write_comments (scl )
420- # Module level
414+ # Module level or non-deprecated class level
421415 else :
422416 self ._write_line (
423417 f"{ val .name } : { value_type } # { val .number } " ,
@@ -570,8 +564,7 @@ def write_messages(
570564 deprecation_scl_field ,
571565 "This field has been marked as deprecated using proto field options." ,
572566 )
573- body = " ..." if not self ._has_comments (scl_field ) else ""
574- wl (f"def { field .name } (self) -> { field_type } :{ body } " )
567+ wl (f"def { field .name } (self) -> { field_type } :{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
575568 if self ._has_comments (scl_field ):
576569 with self ._indent ():
577570 self ._write_comments (scl_field )
@@ -581,8 +574,7 @@ def write_messages(
581574 deprecation_scl_field ,
582575 "This field has been marked as deprecated using proto field options." ,
583576 )
584- body = " ..." if not self ._has_comments (scl_field ) else ""
585- wl (f"def { field .name } (self, value: { field_type } ) -> None:{ body } " )
577+ wl (f"def { field .name } (self, value: { field_type } ) -> None:{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
586578 if self ._has_comments (scl_field ):
587579 with self ._indent ():
588580 self ._write_comments (scl_field )
@@ -604,8 +596,7 @@ def write_messages(
604596 scl_field + [d .FieldDescriptorProto .OPTIONS_FIELD_NUMBER ] + [d .FieldOptions .DEPRECATED_FIELD_NUMBER ],
605597 "This field has been marked as deprecated using proto field options." ,
606598 )
607- body = " ..." if not self ._has_comments (scl_field ) else ""
608- wl (f"def { field .name } (self) -> { field_type } :{ body } " )
599+ wl (f"def { field .name } (self) -> { field_type } :{ ' ...' if not self ._has_comments (scl_field ) else '' } " )
609600 if self ._has_comments (scl_field ):
610601 with self ._indent ():
611602 self ._write_comments (scl_field )
0 commit comments