diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index 893d6355ce..dfb8e6ed22 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -437,7 +437,11 @@ void t_py_generator::init_generator() { << "from thrift.transport import TTransport" << '\n' << import_dynbase_; - f_types_ << "all_structs = []" << '\n'; + if (gen_type_hints_) { + f_types_ << "all_structs: list[typing.Any] = []" << '\n'; + } else { + f_types_ << "all_structs = []" << '\n'; + } f_consts_ << py_autogen_comment() << '\n' <<