Skip to content

Commit 6972464

Browse files
anandoleecopybara-github
authored andcommitted
Change Python .pyi stubs to generated _Optional[] for bool fields same with
other fields. raised in #20372 PiperOrigin-RevId: 755989202
1 parent f49e0f5 commit 6972464

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/google/protobuf/compiler/python/pyi_generator.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,7 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
522522
std::string field_name = std::string(field_des->name());
523523
printer_->Print(", $field_name$: ", "field_name", field_name);
524524
Annotate("field_name", field_des);
525-
if (field_des->is_repeated() ||
526-
field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
527-
printer_->Print("_Optional[");
528-
}
525+
printer_->Print("_Optional[");
529526
if (field_des->is_map()) {
530527
const Descriptor* map_entry = field_des->message_type();
531528
printer_->Print(
@@ -557,11 +554,7 @@ void PyiGenerator::PrintMessage(const Descriptor& message_descriptor,
557554
printer_->Print("]");
558555
}
559556
}
560-
if (field_des->is_repeated() ||
561-
field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) {
562-
printer_->Print("]");
563-
}
564-
printer_->Print(" = ...");
557+
printer_->Print("] = ...");
565558
}
566559
if (has_python_keywords) {
567560
printer_->Print(", **kwargs");

0 commit comments

Comments
 (0)