Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
XuanWang-Amos committed Feb 14, 2024
1 parent e02cf00 commit 9178e09
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/python/helloworld/helloworld_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import helloworld_pb2 as helloworld__pb2

GRPC_GENERATE_VERSION='1.2.0.dev0'
GRPC_GENERATE_VERSION='1.62.0.dev0'
GRPC_VERSION=grpc.__version__

def _first_version_is_lower(version1, version2):
Expand Down
18 changes: 12 additions & 6 deletions src/compiler/python_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) {
}

// Checks if generate code is used with a supported grpcio version.
if(config.grpc_tools_version.size() > 0) {
if (config.grpc_tools_version.size() > 0) {
var["ToolsVersion"] = config.grpc_tools_version;
out->Print(var, "\nGRPC_GENERATE_VERSION='$ToolsVersion$'\n");
out->Print(var, "GRPC_VERSION=grpc.__version__\n\n");
Expand Down Expand Up @@ -763,20 +763,26 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) {
out->Print("return False\n");
}
}
out->Print("\n# If we reach here, the versions are equal up to the compared elements.\n");
out->Print(
"\n# If we reach here, the versions are equal up to the compared "
"elements.\n");
out->Print("# The version without dev0 will be considered lower.\n");
out->Print("return len(version1_list) < len(version2_list)\n");
}

out->Print("\nif _first_version_is_lower(GRPC_GENERATE_VERSION, GRPC_VERSION):\n");
out->Print(
"\nif _first_version_is_lower(GRPC_GENERATE_VERSION, "
"GRPC_VERSION):\n");
{
IndentScope raii_warning_indent(out);
out->Print("warnings.warn(\n");
{
IndentScope raii_warning_string_indent(out);
out->Print("'The stubs you are using were generated by an old'\n"
"+ ' version of grpcio-tools. Please update to the latest'\n"
"+ ' version of grpcio-tools and regenerate the stubs.', RuntimeWarning\n");
out->Print(
"'The stubs you are using were generated by an old'\n"
"+ ' version of grpcio-tools. Please update to the latest'\n"
"+ ' version of grpcio-tools and regenerate the stubs.', "
"RuntimeWarning\n");
}
out->Print(")\n");
}
Expand Down
2 changes: 1 addition & 1 deletion tools/distrib/python/grpcio_tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ py_library(
name = "grpc_tools",
srcs = [
"grpc_tools/__init__.py",
"grpc_tools/protoc.py",
"grpc_tools/grpc_version.py",
"grpc_tools/protoc.py",
],
data = [":well_known_protos"],
imports = ["."],
Expand Down
3 changes: 2 additions & 1 deletion tools/distrib/python/grpcio_tools/grpc_tools/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ int protoc_main(int argc, char* argv[]) {
}

// gRPC Python
grpc_python_generator::GeneratorConfiguration grpc_py_config(grpc_tools_version);
grpc_python_generator::GeneratorConfiguration grpc_py_config(
grpc_tools_version);
grpc_python_generator::PythonGrpcGenerator grpc_py_generator(grpc_py_config);
cli.RegisterGenerator("--grpc_python_out", &grpc_py_generator,
"Generate Python source file.");
Expand Down

0 comments on commit 9178e09

Please sign in to comment.