Giter Site home page Giter Site logo

No stubs for client stubs? about grpc-stubs HOT 5 CLOSED

LanDinh avatar LanDinh commented on July 19, 2024
No stubs for client stubs?

from grpc-stubs.

Comments (5)

gitpushdashf avatar gitpushdashf commented on July 19, 2024

You have to generate type hints for your stubs: https://github.com/nipunn1313/mypy-protobuf

from grpc-stubs.

LanDinh avatar LanDinh commented on July 19, 2024

So the thing is that I did generate the the type hints, and they are all there for the protobufs themselves. But there are no type hints for the stubs on the client side. The version of mypy-protobuf that I'm using is 3.2.0.

from grpc-stubs.

gitpushdashf avatar gitpushdashf commented on July 19, 2024

Did you add __init__.py files for your stubs? If not, may need to set namespace packages to True with mypy.

I may be misunderstanding you, though.

from grpc-stubs.

LanDinh avatar LanDinh commented on July 19, 2024

So what I mean is that I generate my protos with this command:

python -m grpc_tools.protoc -I <proto folder> --python_out=<output folder> --grpc_python_out=<output fuolder> --mypy_out=<output folder> <proto folder>/*.proto

When I then typecheck my project, there are no issues whatsoever with the proto-objects (e.g. I can instantiate them, assign values etc, wrong value types raise type errors etc). But when instantiating the client stub as per my code snippet above (when implementing a gRPC client), type checking produces the error no-untyped-call, as it doesn't find any type hints for the client stub (e.g. which methods are defined on the stubs, which proto objects are expected as input / output etc).

I'm currently silencing this error (# type: ignore[no-untyped-call]), but it would be nice to get actual type hints for it (e.g. to get code completion in IDEs etc, have general type checking on the project, ...)

from grpc-stubs.

gitpushdashf avatar gitpushdashf commented on July 19, 2024

Hmm. Maybe try adding --mypy_grpc_out as well?

from grpc-stubs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.