@@ -419,15 +419,26 @@ def to_json(
419419
420420 # For backwards compatibility of this breaking change in protobuf 5.x which is specific to proto2
421421 # https://github.com/protocolbuffers/protobuf/commit/26995798757fbfef5cf6648610848e389db1fecf
422- if always_print_fields_with_no_presence is not None and including_default_value_fields is not None and always_print_fields_with_no_presence != including_default_value_fields :
423- raise ValueError ("Arguments `always_print_fields_with_no_presence` and `including_default_value_fields` must match" )
422+ if (
423+ always_print_fields_with_no_presence is not None
424+ and including_default_value_fields is not None
425+ and always_print_fields_with_no_presence != including_default_value_fields
426+ ):
427+ raise ValueError (
428+ "Arguments `always_print_fields_with_no_presence` and `including_default_value_fields` must match"
429+ )
424430
425431 # By default, fields with no presense will be included in the results
426432 # when both `always_print_fields_with_no_presence` and `including_default_value_fields` are not set
427- if always_print_fields_with_no_presence is None and including_default_value_fields is None :
433+ if (
434+ always_print_fields_with_no_presence is None
435+ and including_default_value_fields is None
436+ ):
428437 print_fields = True
429438 else :
430- print_fields = always_print_fields_with_no_presence or including_default_value_fields
439+ print_fields = (
440+ always_print_fields_with_no_presence or including_default_value_fields
441+ )
431442
432443 if PROTOBUF_VERSION [0 ] in ("3" , "4" ):
433444 return MessageToJson (
@@ -513,15 +524,26 @@ def to_dict(
513524
514525 # For backwards compatibility of this breaking change in protobuf 5.x which is specific to proto2
515526 # https://github.com/protocolbuffers/protobuf/commit/26995798757fbfef5cf6648610848e389db1fecf
516- if always_print_fields_with_no_presence is not None and including_default_value_fields is not None and always_print_fields_with_no_presence != including_default_value_fields :
517- raise ValueError ("Arguments `always_print_fields_with_no_presence` and `including_default_value_fields` must match" )
527+ if (
528+ always_print_fields_with_no_presence is not None
529+ and including_default_value_fields is not None
530+ and always_print_fields_with_no_presence != including_default_value_fields
531+ ):
532+ raise ValueError (
533+ "Arguments `always_print_fields_with_no_presence` and `including_default_value_fields` must match"
534+ )
518535
519536 # By default, fields with no presense will be included in the results
520537 # when both `always_print_fields_with_no_presence` and `including_default_value_fields` are not set
521- if always_print_fields_with_no_presence is None and including_default_value_fields is None :
538+ if (
539+ always_print_fields_with_no_presence is None
540+ and including_default_value_fields is None
541+ ):
522542 print_fields = True
523543 else :
524- print_fields = always_print_fields_with_no_presence or including_default_value_fields
544+ print_fields = (
545+ always_print_fields_with_no_presence or including_default_value_fields
546+ )
525547
526548 if PROTOBUF_VERSION [0 ] in ("3" , "4" ):
527549 return MessageToDict (
0 commit comments