-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[CodeStyle][UP030][UP031][UP032] using f-string #52062
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
麻烦解决一下冲突,这个 PR 尽可能这周末合了吧,不然不知道要冲突到啥时候(解决完我再 review,之前那个 1000+ 文件的要看吐了) |
请解决下冲突 |
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.
LGTM
目前 %s
-> .format
不是 100% 的,是因为对于 "%s" % var
来说 var 是 tuple/dict/单个值所需要的转写方式完全不一样,因此没办法 100% 转写,Ruff 0.0.258 ( astral-sh/ruff#3600 )对此有所改进,但大多数 case 是没办法解决的,因此这些无法转写是正常的
目前 .format
-> f-string 不是 100% 的,这是由于 Python 机制的问题,Python f-string 里对于部分表达式是不支持的,这个可能在 PEP 701 – Syntactic formalization of f-strings 有改进,但要等到 Python 3.12
cmake/external/flashattn.cmake
Outdated
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.
怎么多了些无关的改动?
Co-authored-by: Liyulingyue <[email protected]>
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.
LGTM
等 CI 过了且无冲突就可以 merge 了
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.
PR types
Others
PR changes
Others
Describe
#51729 case 14 15 16
ruff rules
'{0}{1}'.format(a,b)
to'{}{}'.format(a,b)
,虽然这样更为简洁,但是从代码易读性角度考虑,不建议引入这条规则,但结合32,该规则必须引入。"%s%s" %
to'{}{}'.format()
,两者效果相同,但是使用后者无需指定填充类型,更为简便。f{obj}
=‘{}’.format(obj)
,f string在py3.6后引入,相比原先的'%s'和format,这种方式可读性更好,并且不易出错。是否可以引入本 rule:✅ 可引入。
是否可引入自动修复:✅ 可引入(UP032部分内容仍需手动)。