Skip to content

cattidea/paddlepaddle-stubs

Repository files navigation

PaddlePaddle Stubs WIP

A stubs package as described in PEP 561 for PaddlePaddle.

PyPI - Python Version pypi PyPI - Downloads LICENSE ruff Gitmoji

目前仅针对 Pyright 进行了编写和测试,尚未支持 Mypy(Mypy 相对于 Pyright 太难用了,缺失功能太多),因此目前可能仅仅与 VS Code 的 Pylance 扩展一起工作良好~

Note

本 repo 非运行时库,因此本 repo 中所有示例和单测可能在运行时并不能正常运行,仅仅是为了更加全面和方便对类型进行检查而已。

Usage

pip install paddlepaddle-stubs --pre

此时再打开编辑器,查看编辑器的类型提示~~~

VS Code 推荐配置:

{
   "python.languageServer": "Pylance",
   // 现在有一些类型在 strict mode 工作的并不是很好,推荐先使用 basic mode
   "python.analysis.typeCheckingMode": "basic",
   "python.analysis.inlayHints.functionReturnTypes": true,
   "python.analysis.inlayHints.variableTypes": true,
}

Status

本项目将会作为 【Hackathon 6th】Fundable Project 任务一 —— 为 Paddle 框架 API 添加类型提示(Type Hints)的参考项目,如成功集成至 Paddle,本项目不再单独维护。