diff --git a/Makefile b/Makefile index 14c438a..849e58a 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,7 @@ __default__: @echo "Please specify a target to make" GEN=python3 -m grpc_tools.protoc -I. --python_out=. --python_grpc_out=. --mypy_out=. -GEN2=python3 -m grpc_tools.protoc -I. --python_out=. --python_grpclib_out=. --mypy_out=. -GENERATED=*{_pb2.py,_grpc.py,_grpclib.py,.pyi} +GENERATED=*{_pb2.py,_grpc.py,.pyi} clean: rm -f grpclib/health/v1/$(GENERATED) @@ -18,14 +17,14 @@ clean: rm -f tests/$(GENERATED) proto: clean - $(GEN2) grpclib/health/v1/health.proto - $(GEN2) grpclib/reflection/v1/reflection.proto - $(GEN2) grpclib/reflection/v1alpha/reflection.proto - $(GEN2) grpclib/channelz/v1/channelz.proto + $(GEN) grpclib/health/v1/health.proto + $(GEN) grpclib/reflection/v1/reflection.proto + $(GEN) grpclib/reflection/v1alpha/reflection.proto + $(GEN) grpclib/channelz/v1/channelz.proto cd examples && $(GEN) --grpc_python_out=. helloworld/helloworld.proto cd examples && $(GEN) streaming/helloworld.proto cd examples && $(GEN) multiproc/primes.proto - cd tests && $(GEN2) dummy.proto + cd tests && $(GEN) dummy.proto release: proto ./scripts/release_check.sh diff --git a/examples/mtls/client.py b/examples/mtls/client.py index 072355d..96616f7 100644 --- a/examples/mtls/client.py +++ b/examples/mtls/client.py @@ -7,7 +7,7 @@ from pathlib import Path from grpclib.client import Channel from grpclib.health.v1.health_pb2 import HealthCheckRequest -from grpclib.health.v1.health_grpclib import HealthStub +from grpclib.health.v1.health_grpc import HealthStub DIR = Path(__file__).parent.joinpath('keys') diff --git a/grpclib/channelz/service.py b/grpclib/channelz/service.py index f6c9ccd..58bca88 100644 --- a/grpclib/channelz/service.py +++ b/grpclib/channelz/service.py @@ -9,7 +9,7 @@ from .v1.channelz_pb2 import GetServerSocketsRequest, GetServerSocketsResponse from .v1.channelz_pb2 import GetChannelRequest, GetChannelResponse from .v1.channelz_pb2 import GetSubchannelRequest, GetSubchannelResponse from .v1.channelz_pb2 import GetSocketRequest, GetSocketResponse -from .v1.channelz_grpclib import ChannelzBase +from .v1.channelz_grpc import ChannelzBase class Channelz(ChannelzBase): diff --git a/grpclib/channelz/v1/channelz_grpclib.py b/grpclib/channelz/v1/channelz_grpc.py similarity index 100% rename from grpclib/channelz/v1/channelz_grpclib.py rename to grpclib/channelz/v1/channelz_grpc.py diff --git a/grpclib/health/service.py b/grpclib/health/service.py index c4cacb7..52a8817 100644 --- a/grpclib/health/service.py +++ b/grpclib/health/service.py @@ -8,7 +8,7 @@ from ..utils import _service_name from ..server import Stream from .v1.health_pb2 import HealthCheckRequest, HealthCheckResponse -from .v1.health_grpclib import HealthBase +from .v1.health_grpc import HealthBase if TYPE_CHECKING: diff --git a/grpclib/health/v1/health_grpclib.py b/grpclib/health/v1/health_grpc.py similarity index 100% rename from grpclib/health/v1/health_grpclib.py rename to grpclib/health/v1/health_grpc.py diff --git a/grpclib/plugin/main.py b/grpclib/plugin/main.py index 5a051bb..41a1232 100644 --- a/grpclib/plugin/main.py +++ b/grpclib/plugin/main.py @@ -176,9 +176,8 @@ def _proto2pb2_module_name(proto_file_path: str) -> str: return _base_module_name(proto_file_path) + "_pb2" -def _proto2grpc_module_name(proto_file_path: str, *, legacy: bool) -> str: - suffix = "_grpc" if legacy else '_grpclib' - return _base_module_name(proto_file_path) + suffix +def _proto2grpc_module_name(proto_file_path: str) -> str: + return _base_module_name(proto_file_path) + "_grpc" def _type_names( @@ -207,7 +206,7 @@ def _type_names( parents.pop() -def main(*, _legacy: bool = False) -> None: +def main() -> None: with os.fdopen(sys.stdin.fileno(), 'rb') as inp: request = CodeGeneratorRequest.FromString(inp.read()) @@ -239,7 +238,7 @@ def main(*, _legacy: bool = False) -> None: methods=methods)) file = response.file.add() - module_name = _proto2grpc_module_name(file_to_generate, legacy=_legacy) + module_name = _proto2grpc_module_name(file_to_generate) file.name = module_name.replace(".", "/") + ".py" file.content = render( proto_file=proto_file.name, @@ -250,7 +249,3 @@ def main(*, _legacy: bool = False) -> None: with os.fdopen(sys.stdout.fileno(), 'wb') as out: out.write(response.SerializeToString()) - - -def main_legacy() -> None: - main(_legacy=True) diff --git a/grpclib/reflection/_deprecated.py b/grpclib/reflection/_deprecated.py index fa70ab3..5408ec5 100644 --- a/grpclib/reflection/_deprecated.py +++ b/grpclib/reflection/_deprecated.py @@ -28,7 +28,7 @@ from .v1alpha.reflection_pb2 import ServerReflectionResponse from .v1alpha.reflection_pb2 import ErrorResponse, ListServiceResponse from .v1alpha.reflection_pb2 import ServiceResponse, ExtensionNumberResponse from .v1alpha.reflection_pb2 import FileDescriptorResponse -from .v1alpha.reflection_grpclib import ServerReflectionBase +from .v1alpha.reflection_grpc import ServerReflectionBase class ServerReflection(ServerReflectionBase): diff --git a/grpclib/reflection/service.py b/grpclib/reflection/service.py index b5b4f69..02544b5 100644 --- a/grpclib/reflection/service.py +++ b/grpclib/reflection/service.py @@ -28,7 +28,7 @@ from .v1.reflection_pb2 import ServerReflectionRequest, ServerReflectionResponse from .v1.reflection_pb2 import ErrorResponse, ListServiceResponse from .v1.reflection_pb2 import ServiceResponse, ExtensionNumberResponse from .v1.reflection_pb2 import FileDescriptorResponse -from .v1.reflection_grpclib import ServerReflectionBase +from .v1.reflection_grpc import ServerReflectionBase from ._deprecated import ServerReflection as _ServerReflectionV1Alpha diff --git a/grpclib/reflection/v1/reflection_grpclib.py b/grpclib/reflection/v1/reflection_grpc.py similarity index 100% rename from grpclib/reflection/v1/reflection_grpclib.py rename to grpclib/reflection/v1/reflection_grpc.py diff --git a/grpclib/reflection/v1alpha/reflection_grpclib.py b/grpclib/reflection/v1alpha/reflection_grpc.py similarity index 100% rename from grpclib/reflection/v1alpha/reflection_grpclib.py rename to grpclib/reflection/v1alpha/reflection_grpc.py diff --git a/setup.cfg b/setup.cfg index cc3972e..d365571 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,7 +18,7 @@ skip_covered = true sort = miss [flake8] -exclude = .git,.tox,env,*_pb2.py,*_grpc.py,*_grpclib.py +exclude = .git,.tox,env,*_pb2.py,*_grpc.py max_line_length = 80 [mypy] diff --git a/setup.py b/setup.py index ad9d9f5..3256f74 100644 --- a/setup.py +++ b/setup.py @@ -34,8 +34,7 @@ setup( ], entry_points={ 'console_scripts': [ - 'protoc-gen-python_grpc=grpclib.plugin.main:main_legacy', - 'protoc-gen-python_grpclib=grpclib.plugin.main:main', + 'protoc-gen-python_grpc=grpclib.plugin.main:main', ], }, classifiers=[ diff --git a/tests/dummy_grpclib.py b/tests/dummy_grpc.py similarity index 100% rename from tests/dummy_grpclib.py rename to tests/dummy_grpc.py diff --git a/tests/test_client_channel.py b/tests/test_client_channel.py index 6cca8a1..c0a9254 100644 --- a/tests/test_client_channel.py +++ b/tests/test_client_channel.py @@ -7,7 +7,7 @@ from grpclib.client import Channel from grpclib.testing import ChannelFor from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceStub +from dummy_grpc import DummyServiceStub from test_functional import DummyService diff --git a/tests/test_client_events.py b/tests/test_client_events.py index d0f6089..38e0d43 100644 --- a/tests/test_client_events.py +++ b/tests/test_client_events.py @@ -9,7 +9,7 @@ from grpclib.testing import ChannelFor from grpclib.exceptions import GRPCError from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceStub, DummyServiceBase +from dummy_grpc import DummyServiceStub, DummyServiceBase class DummyService(DummyServiceBase): diff --git a/tests/test_functional.py b/tests/test_functional.py index 3202cf5..ba4a900 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -8,7 +8,7 @@ from grpclib.client import Channel from grpclib.server import Server from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceBase, DummyServiceStub +from dummy_grpc import DummyServiceBase, DummyServiceStub class DummyService(DummyServiceBase): diff --git a/tests/test_health_service.py b/tests/test_health_service.py index 6e78b61..c2d9a88 100644 --- a/tests/test_health_service.py +++ b/tests/test_health_service.py @@ -9,7 +9,7 @@ from grpclib.exceptions import GRPCError from grpclib.health.check import ServiceCheck, ServiceStatus from grpclib.health.service import Health from grpclib.health.v1.health_pb2 import HealthCheckRequest, HealthCheckResponse -from grpclib.health.v1.health_grpclib import HealthStub +from grpclib.health.v1.health_grpc import HealthStub class Check: diff --git a/tests/test_memory.py b/tests/test_memory.py index 673914a..87c29d1 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -10,7 +10,7 @@ from grpclib.exceptions import GRPCError from conn import ClientServer from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceBase, DummyServiceStub +from dummy_grpc import DummyServiceBase, DummyServiceStub class DummyService(DummyServiceBase): diff --git a/tests/test_reflection.py b/tests/test_reflection.py index fc21999..9be2151 100644 --- a/tests/test_reflection.py +++ b/tests/test_reflection.py @@ -10,7 +10,7 @@ from grpclib.reflection.service import ServerReflection from grpclib.reflection.v1.reflection_pb2 import ServerReflectionRequest from grpclib.reflection.v1.reflection_pb2 import ServerReflectionResponse from grpclib.reflection.v1.reflection_pb2 import ErrorResponse -from grpclib.reflection.v1.reflection_grpclib import ServerReflectionStub +from grpclib.reflection.v1.reflection_grpc import ServerReflectionStub from dummy_pb2 import DESCRIPTOR from test_functional import DummyService diff --git a/tests/test_server_events.py b/tests/test_server_events.py index 23ff240..7dc1852 100644 --- a/tests/test_server_events.py +++ b/tests/test_server_events.py @@ -9,7 +9,7 @@ from grpclib.exceptions import GRPCError from grpclib.testing import ChannelFor from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceStub, DummyServiceBase +from dummy_grpc import DummyServiceStub, DummyServiceBase class DummyService(DummyServiceBase): diff --git a/tests/test_stats.py b/tests/test_stats.py index 591743a..add9321 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -10,7 +10,7 @@ from grpclib.testing import ChannelFor from grpclib.exceptions import GRPCError from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceBase, DummyServiceStub +from dummy_grpc import DummyServiceBase, DummyServiceStub def _is_recent(value): diff --git a/tests/test_status_details_codec.py b/tests/test_status_details_codec.py index f26fe52..4ade3fa 100644 --- a/tests/test_status_details_codec.py +++ b/tests/test_status_details_codec.py @@ -8,7 +8,7 @@ from grpclib.exceptions import GRPCError from grpclib.encoding.proto import ProtoCodec, ProtoStatusDetailsCodec from dummy_pb2 import DummyRequest -from dummy_grpclib import DummyServiceStub +from dummy_grpc import DummyServiceStub from test_functional import DummyService diff --git a/tests/test_testing.py b/tests/test_testing.py index 5866cf3..da45f3e 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -3,7 +3,7 @@ import pytest from grpclib.testing import ChannelFor from dummy_pb2 import DummyRequest, DummyReply -from dummy_grpclib import DummyServiceStub +from dummy_grpc import DummyServiceStub from test_functional import DummyService