Repository navigation
[Typing] tensor.prototype.pyi 添加额外的 import 并对 Literal 进行转换 - #65377
Merged
Merged
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
SigureMo
reviewed
Jun 22, 2024
| from paddle.base.dygraph.tensor_patch_methods import ( | ||
| TensorHookRemoveHelper, # noqa: F401 | ||
| ) | ||
| from paddle.base.param_attr import ParamAttr # noqa: F401 |
Collaborator
There was a problem hiding this comment.
Suggested change
| from paddle.base.param_attr import ParamAttr # noqa: F401 | |
| from paddle import ParamAttr # noqa: F401 |
| """ | ||
| convert bad annotation, e.g.: | ||
|
|
||
| "Literal[('raise', 'wrap', 'clip')]" -> "Literal['raise', 'wrap', 'clip']" |
Collaborator
There was a problem hiding this comment.
我这边现在生成的就不带括号
我实验了下,发现是和 Python 版本有关:
from __future__ import annotations
import inspect
from typing import TypeVar, Union, Sequence, Dict, List, Tuple, Any, Literal
def foo(x: Literal["a", "b"]): ...
sig = inspect.signature(foo)
print(sig)
# 3.8
# (x: "Literal[('a', 'b')]")
# 3.9, 3.10 ...
# (x: "Literal['a', 'b']")估计是 3.8 没有 unparse 模块,反编译回字符串出 bug 了,这里记一下吧,方便将来 3.8 退场时候一起清理~
之后我在 #59685 也记一下
co63oc
pushed a commit
to co63oc/Paddle
that referenced
this pull request
Jun 25, 2024
co63oc
pushed a commit
to co63oc/Paddle
that referenced
this pull request
Jun 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Category
User Experience
PR Types
Others
Description
tensor.prototype.pyi 添加额外的 import
目前不确定什么原因,
ParamAttrTensorHookRemoveHelper写入签名的时候,没有使用paddle.xxx.xxx的形式,因此在模板中增加这两个模块修改
Literal"Literal[('raise', 'wrap', 'clip')]"转换为"Literal['raise', 'wrap', 'clip']",去掉中间的括号。Literal写入签名的时候会有括号,但是 vscode 不能正确解析,所以需要将其去掉 ~@SigureMo