Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
【Hackathon 6th Fundable Projects 1 1-1】Add
_typing
module to paddle #63604【Hackathon 6th Fundable Projects 1 1-1】Add
_typing
module to paddle #63604Changes from 8 commits
3b6aba9
b6fc009
a985a5c
f51096e
d48f92f
4151556
8121612
dd9e04e
c9e80de
7418284
0cc8d51
b900efd
d0990dc
9c82616
105b7b4
2b80c3a
6d09d2e
a799bcb
9ce7fae
c45293c
06ef818
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不在pyi里加的话,mypy会找不到,我本地的lsp也找不到,但是我搜索到的资料是优先从pyi中找,其次是py。但这样看起来直接不从py找了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的 ~ 这个 init.pyi 文件现在暂时应该不需要 ~
当时 RFC 里面需要,是因为 Tensor 本来是想加在这里 ~
后面 @SigureMo 建议 Tensor 的 stub 文件 tensor.pyi 直接加在 tensor 目录里面,那么这个 init.pyi 应该暂时不需要了 ~
不然,mypy 优先从 pyi 查找,而这个 init.pyi 又不完整,就会导致 paddle.xxx 都找不到 ~
参考 #63953
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不过,_typing 模块,貌似需要在 init.py 中引入
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一般使用
from . import _typing as _typing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xxx = _xxx
这样写有点问题,比如:这里面
a
类型实际是错的,但是 mypy 检查 pass ~直接使用
=
会使两个类型没啥区别 ~如果要写的话,还是单独列一个类 ~
不过,建议
NPUPlace MLUPlace
暂时不要了,因为 paddle 目前还没有暴露出来这俩个东西,只在 pyi 里面写可能会有异议 ~ 尽量不要增加 _typing 之外属于 api 的东西吧 ~PlaceLike
支持str
应该目前用足够 ~ 这样的话,init.py 和 init.pyi 也不需要这两个东西 ~@SigureMo 看看行不?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocol 应该继承,(或者说是实现,这是组合的概念),而不是直接 assign,NPU 和 MLU 很早之前就在框架内退场了吧大概一年前左右的开源任务
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要了是吧?~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对的,没有就删掉好了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用
tuple
和list
吧 ~另外,需要
from __future__ import annotations
python 3.8 应该不能直接用
tuple
和list
,我这里是 3.8.17你那边测试可能是 mypy 指定版本有问题?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
统一一下版本号吧
mypy==1.10.0