`mypy --strict` fails with `Name "betterproto.ServiceStub" is not defined`
還沒有人認領這個 Issue。
評估
研究方向
從 src/betterproto/init.py 開始,該檔案中會匯入 ServiceStub,並檢查匯出的符號是如何暴露給 mypy 的。透過產生 gRPC 檔案並對產生的程式碼執行 mypy --strict 來重現此問題;當產生的程式碼不再回報 Name "betterproto.ServiceStub" is not defined 時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Summary
mypy --strict fails with Name "betterproto.ServiceStub" is not defined
Reproduction Steps
- Generate some gRPC files from some proto files
- Run
mypyon 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.
- 主要語言
- Python
- 星號
- 1.8k
- 分支
- 235
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
danielgtaylor/python-betterproto 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
-
難度 5/5 一週以上 新手友好度 15/100
-
bug investigation needed
難度 3/5 1-2 天 新手友好度 42/100
-
bug investigation needed
難度 3/5 1-2 天 新手友好度 45/100
-
bug investigation needed
難度 4/5 3-5 天 新手友好度 38/100
danielgtaylor/python-betterproto#676 · 3 則留言 ·
查看 danielgtaylor/python-betterproto 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
iceboundrock/AutoForge#304 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
fossasia/visdom-dev#77 ·
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
aws-cloudformation/cfn-lint#4890 ·
維護者通常 2 天內回覆