Skip to content

Can't find User and CreateUserResult methods in server.py file #23

Description

@Grit550

In the server file, UsersService (inherited from users_service.UsersServicer) overrides CreateUser and GetUsers.
However, there are no methods named User and CreateUserResult in the users_types_pb2 file.
a. User and CreateUserResult are objects defined in the users_types.proto file, which are generated in .pyi files after compilation with the tool.
It seems that the methods in users_types_pb2 are not present in the .pyi file.
This is where the tool called mypy-protobuf comes into play to address this issue. mypy-protobuf generates an independent .pyi file that allows the IDE to assist in suggesting what properties this object has.

Solution:

pip install mypy-protobuf

Adding methods for using grpc-tools `--mypy_grpc_out=./gen-py --mypy_out=./gen-py

This is the executed folder:demo1\grpc-services\protos

python -m grpc_tools.protoc --proto_path=. --python_out=./gen-py --grpc_python_out=./gen-py ./users/*.proto --mypy_grpc_out=./gen-py  --mypy_out=./gen-py  

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions