Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy --strict fails with Name "betterproto.ServiceStub" is not defined #577

Open
3 tasks done
llucax opened this issue May 30, 2024 · 2 comments
Open
3 tasks done
Labels
bug Something isn't working investigation needed

Comments

@llucax
Copy link

llucax commented May 30, 2024

Summary

mypy --strict fails with Name "betterproto.ServiceStub" is not defined

Reproduction Steps

  1. Generate some gRPC files from some proto files
  2. Run mypy on the generated code

Expected Results

mypy passes.

Actual Results

error: Name "betterproto.ServiceStub" is not defined  [name-defined]

Where the stub class is defined in the generated code.

I see the symbol is imported in https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/__init__.py, but it seems like mypy needs imported symbols to be explicitly exported, probably via __all__ or using from x import y as y (see https://peps.python.org/pep-0484/#stub-files).

System Information

$ protoc --version; python --version; pip show betterproto; pip show grpcio-tools
bash: protoc: command not found
Python 3.11.9
Name: betterproto
Version: 2.0.0b6
Location: /home/luca/devel/frequenz-microgrid-betterproto/.direnv/python-3.11.9/lib/python3.11/site-packages
Requires: grpclib, python-dateutil
Required-by: frequenz-microgrid-betterproto
Name: grpcio-tools
Version: 1.63.0
Location: /home/luca/devel/setuptools-betterproto/.direnv/python-3.11/lib/python3.11/site-packages
Requires: grpcio, protobuf, setuptools

(I'm using grpcio-tools to generate the files, not protoc)

Checklist

  • I have searched the issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.
@llucax llucax added bug Something isn't working investigation needed labels May 30, 2024
@llucax
Copy link
Author

llucax commented May 30, 2024

Not sure if #540 might fix this too already.

@embooglement
Copy link

Any updates on this? I'm running into this issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigation needed
Projects
None yet
Development

No branches or pull requests

2 participants